Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]: Extremely slow intellisense depending on schema size and amount #800

Closed
ESchouten opened this issue Jun 21, 2023 · 15 comments
Closed
Labels
bug Something isn't working

Comments

@ESchouten
Copy link

ESchouten commented Jun 21, 2023

What version of drizzle-orm are you using?

0.27.0

What version of drizzle-kit are you using?

0.19.1

Describe the Bug

Intellisense gets unusably slow when providing the schema in the drizzle(sql, { schema }) instantiation.
The intellisense delay depends on the schema amount size, it approaches 8 seconds for us on a Macbook Pro M2 Max with 40 tables, with other, non Macbook M processor people are reporting 10-15 second delays.
It gets faster again when we only provide a subset of the schemas.

Expected behavior

Instant/fast intellisense.

I suppose the TS types are calculated on the go when intellisense activates? This might be the bottleneck. Other libraries generate types and store them on the filesystem. Is this an option for Drizzle?

Environment & setup

Macbook Pro M2 Max

@ESchouten ESchouten added the bug Something isn't working label Jun 21, 2023
@atanaskanchev
Copy link

+1 VSCode gets bogged down and often I have to restart the extension host to get it to load the types

@romulovalez
Copy link

romulovalez commented Jun 21, 2023

+1 With 32 tables and more or less 30 columns per table it takes 14s to fire intellisense, when it used to take 2-3 seconds without drizzle, I measured it using npx tsc --extendedDiagnostics --incremental false --noEmit

Using the trick of casting the column names as string (ex.: integer('id' as string)) reduces the time to 5 seconds and only generates 40,000 new types (this would still be very high, wouldn't it?), without this trick the types count raised to +500,000 and it takes 14 seconds to load intellisense, as i said above.

@romulovalez
Copy link

Related issue: #437

@ESchouten
Copy link
Author

Update from the Drizzle team: Tweet
"We'll make it a priority on Jul"

@AndriiSherman AndriiSherman pinned this issue Jun 22, 2023
@oscarhermoso
Copy link

oscarhermoso commented Jun 29, 2023

Nice, the column name as string workaround brings my tsc down from 4.9 seconds to 3.1 seconds (was 2.8s before adding Drizzle).

Regex find and replace (^.+?'\w+') with $1 as string in my schema directory patched 99% of the column names.

@MAST1999
Copy link

Nice, the column name as string workaround brings my tsc down from 4.9 seconds to 3.1 seconds (was 2.8s before adding Drizzle).

Regex find and replace (^.+?'\w+') with $1 as string in my schema directory patched 99% of the column names.

This actually does help!
But when I was reading it I was a bit confused so here's how I think it works in simple terms.

The issue is that drizzle orm is generating a lot of types by inferring things and most of that inferring depends on the column names. So if we add as string to the column names which otherwise would be a literal string it would reduce the number of types generated.

export const ticket = pgTable(
  'ticket',
  {
    id: uuid('id' as string).primaryKey().notNull(),
  });

I ended up using (^\s\s.+?'\w+') because I had 2 spacing in my tables (thanks to prettier) and this correctly selected all my columns.

@jeffminsungkim
Copy link

Any updates? This is very annoying tbh.

@ngregrichardson
Copy link
Contributor

Seems like it'll be released sometime in August according to this thread on Discord

@jeffminsungkim
Copy link

Seems like it'll be released sometime in August according to this thread on Discord

Thanks for letting me know 👍🏼

@jakebailey
Copy link

FYI I just merged a perf fix in TS (microsoft/TypeScript#55224) which mitigates at least half of the slowness in microsoft/TypeScript#54939 / #870.

I'm not sure how much it'll help other projects in general without having them to test, but feel free to try the build in microsoft/TypeScript#55224 (comment) or wait for the next nightly build to see how much it helps.

As with all things perf, it's never just one thing 😄

@AndriiSherman
Copy link
Member

We've released [email protected] with improvements for IntelliSense

We've run the diagnostics on a database schema with 85 tables, 666 columns, 26 enums, 172 indexes, and 133 foreign keys. We've optimized internal types which resulted in 430% speed up in IntelliSense.

https://github.com/drizzle-team/drizzle-orm/releases/tag/0.28.0

@AndriiSherman AndriiSherman unpinned this issue Aug 7, 2023
@jacobhjkim
Copy link

Is anyone still having this issue? I am using Webstorm on m1 macbook pro, with about 10 tables with 15 cols each. 😢

@tmoran-stenoa
Copy link

@jacobhjkim I haven't had this issue since they pushed the fix last year. Intellisense has been running decently fast, even though my schema has grown a lot bigger

@jacobhjkim
Copy link

@jacobhjkim I haven't had this issue since they pushed the fix last year. Intellisense has been running decently fast, even though my schema has grown a lot bigger

Ok, so intellisense seems to working fine on my VS Code. So it's probably something to do with Webstorm. I will test more and report back.

@andreichirkov
Copy link

andreichirkov commented Sep 13, 2024

Intellisense working on VS Code, but don't work on Webstorm. MBP m1.
I only see: Fetching Documentation...

It is problem for me, because I can't working with VS Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests