-
Notifications
You must be signed in to change notification settings - Fork 238
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
Case of extremely slow type checking #867
Comments
Forgot to add that I'm immensely appreciative of the work done on Kysely. It's a great tool that lets us work with our database without fear. 🙏 |
Hey 👋 Does this improve performance? const demoQuery = (db: Kysely<DB>) =>
db
.selectFrom((eb) =>
eb
.selectFrom("my_table")
.where("my_table.id", "in", [1, 2, 3])
.selectAll()
.as("test")
)
.selectAll(); |
Hi! I'm away from my computer, as I'm on vacation right now, but as soon as I'm back I'll give it a try! |
@igalklebanov It did improve it quite a bit! But it's still not great… Files: 435
Lines: 119236
Identifiers: 112578
Symbols: 246727
Types: 7593
Instantiations: 1355207
Memory used: 212941K
I/O read: 0.05s
I/O write: 0.00s
Parse time: 0.69s
Bind time: 0.30s
Check time: 11.30s
Emit time: 0.00s
Total time: 12.29s |
Hello there, and thank you for the amazing project, I introduced the typesafe query builder into our project which containes alot of tables. I wonder if Kysely is made for a scale of 100s and 100s of tables with 100s of complex queries. Without Kyseley type checking is around 8 seconds, after starting generating the types of our db and only include ~100tables and written complex queries which use the expression builder to compose sub queries with joints. The query results are efficient and build for purpose And I start already plunching in the 60 seconds type checking. If this performance is odd I will go deeper into stats and post them here. TypeScript version 5.1.6 |
I'd strongly consider splitting data access to several Kysely instances with their own limited view of the world, if possible. Kysely is built around, for the most part, string literal type comparisons. The more unique column and table names in |
thank you for your quick reply, I will give this a try. |
would a split into multiple schemas on the same interface, differentiated by the prefix, alleviate the performance issue? |
I'm not able to reproduce this. Any chance to get a full reproduction? A complete project I can run and profile? |
Yeah, sure. Here's a Github gist with the relevant files, including an anonymized version of the database types. |
A big issue on our project as well. Please let me know if there is anything I could assist with. |
I have a query pattern that degrades tsc type checking performance to an outsized degree. It involves a nested query in
selectFrom
, and a simplewhere
clause.This is my most minimal reproduction:
With the
where
line indicated by the comment, runningtsc --diagnostics --noEmit
takes about 30 seconds, whereas after removing it it takes about a second.TypeScript diagnostics with
where
:TypeScript diagnostics WITHOUT
where
:My DB has a large number of tables, so I'm sure that's part of the issue, but I never had this problem until I added this particular pathological query.
I'm using:
kysely
v0.27.2typescript
v5.3.3Edit: Here's a Github gist with all of the files needed to reproduce this issue.
The text was updated successfully, but these errors were encountered: