-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Schema size affects runtime speed #14695
Comments
Problem: when we have a freshly instantiated client (haven't done any queries yet) and we execute multiple queries at the same event loop tick, each one of them will start `getDMMF` request, which could be quite slow. Fixed by caching the results promise first time `getDMMF` is called and returning the same promise for subsequent calls. Fix #14695
I was able to reproduce and fix it. Here is what I am getting after the fix:
First call is still around 2 times slower than subsequent ones, but not to the same degree as reported here. Reason why it's not quite back to the times it was before is that in 3.x we've bundled DMMF with generated client, where in 4.x we get it at runtime. |
Update:
The fix won't make it into 4.2.0 release, but will be published in 4.2.1 shortly afterwards. @DarioSiroki thanks for the report and great reproduction! |
No problem, thanks for the quick fix! |
Problem: when we have a freshly instantiated client (haven't done any queries yet) and we execute multiple queries at the same event loop tick, each one of them will start `getDMMF` request, which could be quite slow. Fixed by caching the results promise first time `getDMMF` is called and returning the same promise for subsequent calls. Fix #14695
Problem: when we have a freshly instantiated client (haven't done any queries yet) and we execute multiple queries at the same event loop tick, each one of them will start `getDMMF` request, which could be quite slow. Fixed by caching the results promise first time `getDMMF` is called and returning the same promise for subsequent calls. Fix #14695
Problem: when we have a freshly instantiated client (haven't done any queries yet) and we execute multiple queries at the same event loop tick, each one of them will start `getDMMF` request, which could be quite slow. Fixed by caching the results promise first time `getDMMF` is called and returning the same promise for subsequent calls. Fix #14695
Problem: when we have a freshly instantiated client (haven't done any queries yet) and we execute multiple queries at the same event loop tick, each one of them will start `getDMMF` request, which could be quite slow. Fixed by caching the results promise first time `getDMMF` is called and returning the same promise for subsequent calls. Fix #14695
Released in 4.2.1 |
Bug description
After migration from 3.15.2 to 4.0.0, my production server has started running out of memory during syncs between 2 databases which occur every 45 seconds. The provided client code is a simplified version of the production code.
Test code is provided below. It builds 500 upsert queries and executes them via
$transaction
Prisma 4.1.1
With 201 tables in schema:
With 1 table in schema:
Prisma 3.15.2
With 201 tables in schema:
With 1 table in schema:
By the way, this also happens with prisma.table.create. I have not tried other cases.
How to reproduce
There is a difference in runtime with schema size.
Expected behavior
Prisma information
Find the prisma schema at pastebin
Environment & setup
Prisma Version
The text was updated successfully, but these errors were encountered: