notiz-dev / prisma-dbml-generator

Prisma DBML Generator
MIT License
684 stars 36 forks source link

Performance: Prisma generate freezes with large schema with dbml generator #38

Open marcjulian opened 2 years ago

marcjulian commented 2 years ago

image there seems to be another issue that isn't caught by the tests, because when generating in a reasonably sized project it's frozen, when removing the dbml generator provider it does generate correctly

Originally posted by @PabloSzx in https://github.com/notiz-dev/prisma-dbml-generator/issues/37#issuecomment-1174157553

marcjulian commented 2 years ago

@PabloSzx let's track the performance issue here. We should setup a large dummy/test schema to find out the bottleneck of this generator. How large (lines of code) is the prisma.schema where it froze?

PabloSzx commented 2 years ago

Is ~650 lines

yourbuddyconner commented 1 year ago

Think I have another instance of this, my schema is ~400 lines long, with many enums peppered all over which I think is affecting graph complexity.

marcjulian commented 1 year ago

@yourbuddyconner is it freezing or just taking for a long time to generate? Are thus enums with a few or a lot of entries?

I guess will need to create a test schema with lots of entries, relationships and enums to test it out.

yourbuddyconner commented 1 year ago

I feel like it was hanging, I profiled the process and it wasn't using a considerable amount of CPU or memory, so my conclusion was a weird hang of some kind but that wasn't based on a deep dive or anything.

I am using a schema generated by Prisma, which includes an average of ~1 enum across 20+ models with a web of relations across them. The enums have <10 options, averaging 2-4, and idk if that affects performance at all.

Anecdotally, I have been having difficulty generating ERDs with this schema across a variety of tools, with the only reliable one being PGAdmin. Prisma might be using some fancy Postgres stuff that is specific to a newer version of PSQL.