drizzle-team / drizzle-graphql

Automatically generate GraphQL schema or customizable schema config fields from Drizzle ORM schema
https://www.npmjs.com/package/drizzle-graphql
Apache License 2.0
34 stars 1 forks source link

poor performance after implementation `deep relations` #11

Closed Edsol closed 1 month ago

Edsol commented 1 month ago

I am using the extension on some example databases (mysql and postgres) to develop my extension.

I have big memory problems on version 0.7.x of the extension

Large MySql database info (via Apollo):

mysql large db

Small MySql database info (via Apollo):

mysql small db

Large Postgres database info (via Apollo):

postgres larege db

Small Postgres database info (via Apollo):

postgres small db

version 0.6.0

memory used:

version 0.7.2

memory used:

Sukairo-02 commented 1 month ago

I'll see what I can do about that, but since I'm already caching and reusing whatever is possible, it might be the case that there's nothing left to improve

Edsol commented 1 month ago

to limit the load, could a configuration parameter to exclude or limit the depth of relationships be a temporary solution?

Sukairo-02 commented 1 month ago

Yes, that's possible for the runtime No idea how to implement the types for that case though

Sukairo-02 commented 1 month ago

Actually, I might be able to optimize something here. Just noticed an awfully big amount of inputs, I should be able to reduce that, expect a patch soon.

Sukairo-02 commented 1 month ago

Can you try it with v0.7.3? That should reduce memory usage a lot. If that's not enough for it to become usable on large schemas again, then I'll add depth limiter.

Edsol commented 1 month ago

memory goes up less quickly but after a couple of minutes of processing it still exceeds 20GB SCR-20240528-qasn

Sukairo-02 commented 1 month ago

Rise in memory usage was to be expected, but that's way too much. I see. I'll keep optimizing it as much as possible.

Sukairo-02 commented 1 month ago

I've added depth limiter for now, hopefully I'll be able to do something about it in the future.

Edsol commented 1 month ago

the depth limit works, it may be the right compromise on rather large databases with many relationships.

Thanks

anthonyhoegberg commented 2 weeks ago

I've added depth limiter for now, hopefully I'll be able to do something about it in the future.

Is it possible to configure the depth?

EDIT:

Sorry, i saw there is a depth config in

const { entities } = buildSchema(schema, {
  relationsDepthLimit: 5
});