-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
sql, opt: avoid full scans in mutation queries #137781
base: master
Are you sure you want to change the base?
Conversation
Your pull request contains more than 1000 changes. It is strongly encouraged to split big PRs into smaller chunks. 🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf. |
1e19a05
to
cff59af
Compare
Informs cockroachdb#79683 Release note (sql change): Added support for a new index hint, AVOID_FULL_SCAN, which will prevent the optimizer from planning a full scan for the specified table if any other plan is possible. The hint can be used in the same way as other existing index hints. For example, SELECT * FROM table_name@{AVOID_FULL_SCAN};. Note that a full scan of a partial index may still be preferred by the optimizer, unless AVOID_FULL_SCAN is used in combination with a specific partial index via FORCE_INDEX=index_name. This hint is similar to NO_FULL_SCAN, but will not error if a full scan cannot be avoided.
cff59af
to
07c79dc
Compare
Fixes cockroachdb#79683 Release note (sql change): Added a new session setting avoid_full_table_scans_in_mutations, which when set to true, causes the optimizer to avoid planning full table scans for mutation queries if any other plan is possible. It now defaults to true.
Removed a comment that references a function parameter that no longer exists. Release note: None
07c79dc
to
e599fcd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: complete! 0 of 0 LGTMs obtained
pkg/sql/opt/exec/execbuilder/testdata/update
line 404 at r3 (raw file):
└── • render │ └── • limit
Need to investigate why we lost the top k here
pkg/sql/opt/exec/execbuilder/testdata/unique
line 5707 at r3 (raw file):
vectorized: true · • root
This seems concerning that we're no longer getting the insert fast path here.
opt,sql: support hint to avoid full scan
Informs #79683
Release note (sql change): Added support for a new index hint,
AVOID_FULL_SCAN
, which will prevent the optimizer from planning afull scan for the specified table if any other plan is possible. The
hint can be used in the same way as other existing index hints. For
example,
SELECT * FROM table_name@{AVOID_FULL_SCAN};
. Note that afull scan of a partial index may still be preferred by the optimizer,
unless
AVOID_FULL_SCAN
is used in combination with a specific partialindex via
FORCE_INDEX=index_name
. This hint is similar toNO_FULL_SCAN
,but will not error if a full scan cannot be avoided.
sql,opt: add setting avoid_full_table_scans_in_mutations
Fixes #79683
Release note (sql change): Added a new session setting
avoid_full_table_scans_in_mutations
, which when set to true, causesthe optimizer to avoid planning full table scans for mutation queries
if any other plan is possible. It now defaults to true.
opt: remove a stale comment above optbuilder.buildScan
Removed a comment that references a function parameter that no longer
exists.
Release note: None