-
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.
constraint: perform cancel checking when combining constraints
Previously, the combining of constraint spans when one constraint is a suffix of the other could take a long time and cause the `statement_timeout` session setting to not be honored when each constraint has hundreds or thousands of spans. The issue is that `constraint.Combine` has double nested loops to consider every combination of one span from one constraint with one span of the other constraint. The building of possibly millions of spans may take excessive CPU time and allocate excessive amounts of memory. The fix is to maintain a counter in `constraint.Combine` and call the query cancel check function every 16 iterations. The cancel check function itself will check for query timeout every 1024 iterations, so effectively every 16K iterations `constraint.Combine` will perform cancel checking and abort the query if the timeout has been reached. Epic: none Fixes: #111862 Release note (bug fix): This patch fixes an issue where the optimizer fails to honor the `statement_timeout` session setting when generating constrained index scans for queries with large IN lists or `= ANY` predicates on multiple index key columns, which may lead to an out of memory condition on the node.
- Loading branch information
Mark Sirek
committed
Oct 8, 2023
1 parent
4637e51
commit 56a18e0
Showing
4 changed files
with
95 additions
and
4 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