diff options
author | Alexander Korotkov <akorotkov@postgresql.org> | 2024-11-29 09:48:29 +0200 |
---|---|---|
committer | Alexander Korotkov <akorotkov@postgresql.org> | 2024-11-29 09:52:12 +0200 |
commit | 5bba0546eecb32f4ff9388815727304823940ef6 (patch) | |
tree | d55b616a3fbcdc92855d6f3d2d6889690157ed87 /src/backend/optimizer | |
parent | b6612aedc53a6bf069eba5e356a8421ad6426486 (diff) | |
download | postgresql-5bba0546eecb32f4ff9388815727304823940ef6.tar.gz postgresql-5bba0546eecb32f4ff9388815727304823940ef6.zip |
Skip not SOAP-supported indexes while transforming an OR clause into SAOP
There is no point in transforming OR-clauses into SAOP's if the target index
doesn't support SAOP scans anyway. This commit adds corresponding checks
to match_orclause_to_indexcol() and group_similar_or_args(). The first check
fixes the actual bug, while the second just saves some cycles.
Reported-by: Alexander Lakhin
Discussion: https://postgr.es/m/8174de69-9e1a-0827-0e81-ef97f56a5939%40gmail.com
Author: Alena Rybakina
Reviewed-by: Ranier Vilela, Alexander Korotkov, Andrei Lepikhov
Diffstat (limited to 'src/backend/optimizer')
-rw-r--r-- | src/backend/optimizer/path/indxpath.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/backend/optimizer/path/indxpath.c b/src/backend/optimizer/path/indxpath.c index d827fc9f4d9..5d102a0d371 100644 --- a/src/backend/optimizer/path/indxpath.c +++ b/src/backend/optimizer/path/indxpath.c @@ -1354,8 +1354,11 @@ group_similar_or_args(PlannerInfo *root, RelOptInfo *rel, RestrictInfo *rinfo) { IndexOptInfo *index = (IndexOptInfo *) lfirst(lc2); - /* Ignore index if it doesn't support bitmap scans */ - if (!index->amhasgetbitmap) + /* + * Ignore index if it doesn't support bitmap scans or SAOP + * clauses. + */ + if (!index->amhasgetbitmap || !index->amsearcharray) continue; for (colnum = 0; colnum < index->nkeycolumns; colnum++) @@ -3248,6 +3251,10 @@ match_orclause_to_indexcol(PlannerInfo *root, Assert(IsA(orclause, BoolExpr)); Assert(orclause->boolop == OR_EXPR); + /* Ignore index if it doesn't support SAOP clauses */ + if (!index->amsearcharray) + return NULL; + /* * Try to convert a list of OR-clauses to a single SAOP expression. Each * OR entry must be in the form: (indexkey operator constant) or (constant |