-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
opt,sql: support hint to avoid full scan
Added a hint to avoid full scans (see release note below for details). To support this change, added a field to memo.Cost with a new type memo.CostFlags, which contains a number of boolean flags and supports "multi-dimensional costing". This allows the optimizer to compare plans based on the flags set in addition to the single-dimensional float64 cost. For example, plans with the new FullScanPenalty cost flag enabled will always be more expensive than plans without any cost flags, even if the base float64 cost is lower. The new CostFlags type also includes a flag for HugeCostPenalty, which must be set for plans with "hugeCost". This ensures that existing hints that use hugeCost still work if some other cost flags are set, since HugeCostPenalty takes precedence over other cost flags. This new CostFlags field is needed to support hints that do not cause an error if the optimizer cannot find a plan complying with the hint. This is needed because the previous approach of simply using "hugeCost" to avoid certain plans meant that if such plans were unavoidable, we could not effectively compare plans with cost greater than hugeCost due to loss of floating point precision. Informs #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};. This hint is similar to NO_FULL_SCAN, but will not error if a full scan cannot be avoided. Note that normally a full scan of a partial index would not be considered a "full scan" for the purposes of the NO_FULL_SCAN and AVOID_FULL_SCAN hints, but if the user has explicitly forced the partial index via FORCE_INDEX=index_name, we do consider it a full scan.
- Loading branch information
Showing
24 changed files
with
436 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.