-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Not all condition in SQL got pushdown in TiKV Table range scan #16798
Comments
If I understand correctly, what you want is |
a fine-grained range decision? using what you can grab as much as possible? |
Same as pingcap/tidb#41598 |
Here is an example of a select query plan that has to scan over 2 entire pks. I have obfuscated the real PK and SK fields. This a select statement similar to the delete statement seen in the description
This range only has 4000 keys in it but the explain analyze above shows that it processed 1050351 total keys (roughly number of keys under primary_key_start U primary_key_end). The range of the innermost TableRangeScan is range:
Total number of keys under primary_key_start:
Total number of keys under primary_key_end:
(in this table each primary_key has similar cardinality of secondary_keys underneath) Generally, we want to be able to efficiently handle queries that scan between Another option would to be able to use the cleaner tuple syntax for this type of query. This syntax would be more concise but would perform even worse and result in a full table scan:
|
@cgtz Could you please add DDL? |
Yes, this condition pushdown issue is with the select part of the delete and the same issue occurs with normal selects.
|
Did some analysis and seems the range intersection is limited to the leading column. Below, is a simple example. Q1 is ((a1>1) or (a1=1 and b1 > 10)) and we get the correct range:(1 10,1 +inf], (1,+inf]
|
Feature Request
Is your feature request related to a problem? Please describe:
In the query slow log we can see only the primary key range of the where condition is pushed down
This results a 1050324 row scan on tikv instead of 4000
Describe the feature you'd like:
Describe alternatives you've considered:
Teachability, Documentation, Adoption, Migration Strategy:
The text was updated successfully, but these errors were encountered: