Skip to content
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

QE: Batch huge IN queries into smaller batches #579

Closed
pimeys opened this issue Mar 16, 2020 · 0 comments
Closed

QE: Batch huge IN queries into smaller batches #579

pimeys opened this issue Mar 16, 2020 · 0 comments
Assignees
Labels
tech/engines/query engine Issue in the Query Engine
Milestone

Comments

@pimeys
Copy link
Contributor

pimeys commented Mar 16, 2020

In all our supported databases a big enough IN query will panic and crash due to the database not allowing too large set of variables. It's especially easy to replicate with a big enough database due to the relation queries joining the data with a huge IN statement.

Example:

query A {
  findManyUser { address { street } }
}

If having thousands of users (between 5000-10000 or more), the address query will be including a filter with user_id IN (thousands of ids) and the database will error, causing a panic.

We could instead load the addresses in batches of maximum 5000 ids and concatenating the results in the connector.

Things to be aware of:

  • Databases will dedup ids in an IN statement. For batched statements, the deduplicating should be done in the connector
  • Ordering will cause trouble. For batched queries, the ordering needs to happen in the connector.
@pimeys pimeys added the tech/engines/query engine Issue in the Query Engine label Mar 16, 2020
@pimeys pimeys added this to the Preview 25 milestone Mar 16, 2020
@pimeys pimeys self-assigned this Mar 16, 2020
@pimeys pimeys closed this as completed Mar 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tech/engines/query engine Issue in the Query Engine
Projects
None yet
Development

No branches or pull requests

1 participant