Skip to content

Add IN operator limit#8519

Closed
wolfgangcolsman wants to merge 2 commits intotrinodb:masterfrom
zontal:in_operator_limit
Closed

Add IN operator limit#8519
wolfgangcolsman wants to merge 2 commits intotrinodb:masterfrom
zontal:in_operator_limit

Conversation

@wolfgangcolsman
Copy link
Copy Markdown

The limit of the values per IN operator depends on the database. E.g. Oracle allows only up to 1,000 IN list values in a SQL statement.

@tooptoop4
Copy link
Copy Markdown
Contributor

is this missing the change on Oracle class? Similarly Postgres also has a limit. Does the remainder part in QueryBuilder.java create separate ORs for another set of IN?

@wolfgangcolsman
Copy link
Copy Markdown
Author

is this missing the change on Oracle class? Similarly Postgres also has a limit. Does the remainder part in QueryBuilder.java create separate ORs for another set of IN?

I don't think the Oracle and Postgres need to be changed. They would maybe need to set the correct property value.

If I understand the code correctly, the list of INs will be ORed below

@findepi
Copy link
Copy Markdown
Member

findepi commented Jul 17, 2021

What is the purpose of the change? At the first sight it looks redundant over domain-compaction-threshold. What am i missing?

@wolfgangcolsman
Copy link
Copy Markdown
Author

What is the purpose of the change? At the first sight it looks redundant over domain-compaction-threshold. What am i missing?

Compaction threshold converts a list of values into a range query. This has it's issues e.g with guids.

The proposed change here addresses the situation that more than N values make it into the IN statement, when setting the compaction value > N

@findepi
Copy link
Copy Markdown
Member

findepi commented Jul 19, 2021

@wolfgangcolsman in our testing internally, we found our that databases typically have performance problems with large IN queries.
Also, there are PreparedStatement limits, query text limits and such, which mean that trying to push very large domains may hit other limitations.

What is the scenario you're trying to improve? What's the domain size where you see full pushdown beneficial from query performance perspective?

@wolfgangcolsman
Copy link
Copy Markdown
Author

wolfgangcolsman commented Jul 19, 2021

@findepi Our use case is large dynamic filters where we have thousands of records returned per FK in the IN clause. Full table scans are not an option, and range queries do not work because FKs use GUIDs

@colebow
Copy link
Copy Markdown
Member

colebow commented Oct 27, 2022

👋 @wolfgangcolsman - this PR has drawbacks that don’t align with our preferred approach, so we’re not going to proceed with this implementation. If you'd like to continue the discussion on this at any point in the future, feel free to re-open and chime in.

@colebow colebow closed this Oct 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

4 participants