DT
Drizzle Team•5mo ago
code9

slow code suggestions

hey guys, after adding drizzle to our code base, we've seen a drastic increase in code suggestion/completion times (be that vscode intellisense or vim lsp). there's seems to be a closed issue on this topic in drizzle's github repo, but it doesn't seem to be solved. our db is around 450 tables and 4k columns. I've upgraded to drizzle 0.32 and drizzle-kit 0.23, but it seems to be the same
7 Replies
rphlmr ⚡
rphlmr ⚡•5mo ago
Hey đź‘‹ Are they all in the same file? You are right, I remember an issue like that and some super wizard helped to solve that. Cc @Luxaritas đź‘‹ if you have an idea
Luxaritas
Luxaritas•5mo ago
My solution at one point was to specify the generic parameter which correlates to the column name to just be string, which would cut down on the number of distinct types (though note that this breaks compatibility with eg the Kysely integration which relies on that info). Since then some of the typings changed which at least mostly improved the situation, so I removed that. I don’t know if this is a new regression (I haven’t upgraded in a while) or if you’re hitting a type performance issue that’s stemming from some other aspect of your schema
code9
code9OP•5mo ago
@Raphaël M (@rphlmr) ⚡ yes, they are all in the same file (as its generated by drizzle-kit introspection)
rphlmr ⚡
rphlmr ⚡•5mo ago
đź‘Ť I would suggest splitting them into multiple files, but at the same time, I am not sure if it will fix the issue and I would not want to waste your time. https://orm.drizzle.team/kit-docs/config-reference#schema
Drizzle ORM - Config Reference
Drizzle ORM is a lightweight and performant TypeScript ORM with developer experience in mind.
rphlmr ⚡
rphlmr ⚡•5mo ago
I still follow Luxaritas suggestion in my biggest project:
id: uuid("id" as string)
.primaryKey()
.defaultRandom(),
id: uuid("id" as string)
.primaryKey()
.defaultRandom(),
adding a as string (it only impact the column name, not the column type)
code9
code9OP•4mo ago
Ill try with as string first and then splitting it thanks! a little update; so adding the as string bit reduced the suggestion time from over 20 secs, to 8-9 seconds on our slowest workstations and about 2-4 secs for the faster ones. any thoughts on how to get this to under 2 secs? I split the schema in 2 files first to see if there was any improvement, but there was no noticeable improvement, although perhaps splitting in more than 2 files would work? but even so, the schema is about 8k lines and we previously used prisma where the schema was like 2 times that (for the same tables), so it kind of doesnt feel like the issue is the schema file length. @Raphaël M (@rphlmr) ⚡ @Luxaritas
html_extraordinaire
html_extraordinaire•4mo ago
The difference is probably that Prisma generates the types every time you change the schema and run prisma generate and Drizzle doesn't. Every time your editor needs to find a type, Drizzle is going to look at some table in your schema file first. I do wonder if that means breaking those two big files into smaller ones would make TypeScript inference faster but I doubt it. That makes sense right? I think Drizzle's type system probably leans more heavily on type gymnastics. Also I used to work at a pretty big corporation and they had really strict security standards. They ran like two different endpoint security programs but it really slowed things down. I remember Intellisense in my editor being slow as hell after they added that second one. If you've got endpoint security that could also be it.
Want results from more Discord servers?
Add your server