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
[YSQL] For range sharded database, index scan with pk filter is slower than sequential scan #16178
Comments
|
Follow up on cost model: Should we adjust the threshold for switching between sequential scan and index scan for the above queries. |
(updated with pk full scan w/o predicate case and made the search condition truly full range for more fair comparisons. Non-negligible overhead exists in Index Only Scan, too, with a range predicate.) Index only scan using a secondary index on range key with or w/o predicate runs about the same or slightly faster than Seq Scan w/o predicate. On the other hand, the Index Scan using the pkey takes almost the same amount of time as the Seq Scan with remote filter that is evaluated for every single row.
|
… boundary conditions Summary: This change checks if the Index scan condition can be encoded in bounds for the scan. If conditions are encoded in bound keys, then based on the new flag `index_scan_prefer_sequential_scan_for_boundary_condition`, we will disable use of ScanChoices (aka skip scan). To determine if a condition is encoded in bound key or not, we use the following logic: 1. We check for prefix conditions which are encoded in both min and max bound. For ex, equals on a key column. 2. If there is only one column min/max bound is specified after the prefix conditions. Note: this change only optimizes the range sharded tablets. This can be extended for hash sharded tablets when there is an equal condition for hash. Jira: DB-5611 Test Plan: ./yb_build.sh --sj ./build/latest/tests-docdb/scan_choices-test Reviewers: tnayak, tverona, rthallam Reviewed By: tnayak Subscribers: ybase Differential Revision: https://phorge.dev.yugabyte.com/D28560
…can with boundary conditions" Summary: This reverts commit 2afd4fd. Reverting due to correctness issues. Jira: DB-5611 Test Plan: Jenkins Reviewers: rthallam Reviewed By: rthallam Subscribers: tnayak, ybase Differential Revision: https://phorge.dev.yugabyte.com/D28978
Jira Link: DB-5611
Description
For partition key filters in range shaded database, we prefer Local Skip scan today which validates each row. Instead, we can use sequential scan with adjusted lower and upper bound based on the filter.
The text was updated successfully, but these errors were encountered: