You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My company has 132 tables in PostgreSQL, which we've pulled into a schema.prisma file to generate models. This resulted in a types.py file with approximately 1 million lines. Due to the large size and the frequent calls to model_rebuild function within the models.py file, interactions with the library have become very slow.
As a result:
The CLI startup time is around 10-20 seconds.
Importing the module with from prisma import Prisma also takes 10-20 seconds and consumes around 1GB of RAM.
For traditional web applications like FastAPI or Django, this cold start is acceptable since you can start the application once and keep it running. However, for serverless applications, this performance is problematic because you are charged for startup time and resource usage.
Is it possible to fix this somehow or is the whole idea of generation not applicable to python because of its speed?
Env: Macos M2 Pro, 16 GB ram, python ^3.10
The text was updated successfully, but these errors were encountered:
leemurus
changed the title
Library import takes too long (cold start problem)
Importing Prisma takes too long (cold start issue)
Oct 19, 2024
Hey anton, thanks for the report. Have you enabled recursive types? If you haven't, I would strongly recommend doing so as that should significantly shorten the generated types.py file.
Hey RobertCraigie! What do you mean about enable recursive types? As I understand it, this will increase the file size on the contrary, since there will be more models. On the contrary, we reduced them to a minimum value of 2 and made the current measurements at this figure.
My company has 132 tables in PostgreSQL, which we've pulled into a
schema.prisma
file to generate models. This resulted in atypes.py
file with approximately 1 million lines. Due to the large size and the frequent calls tomodel_rebuild
function within themodels.py
file, interactions with the library have become very slow.As a result:
For traditional web applications like FastAPI or Django, this cold start is acceptable since you can start the application once and keep it running. However, for serverless applications, this performance is problematic because you are charged for startup time and resource usage.
Is it possible to fix this somehow or is the whole idea of generation not applicable to python because of its speed?
Env: Macos M2 Pro, 16 GB ram, python ^3.10
The text was updated successfully, but these errors were encountered: