Skip to content

Commit

Permalink
Revert "Fix handling of unavailable indexes in Scan hints"
Browse files Browse the repository at this point in the history
This reverts commit a3646e1, that we have found to do more weird
plan manipulations by ignoring in some cases Parallel hints when they
should not.

The behavior before this commit has also some historical weirdness, but
impacting the stability of plans is not a good idea in stable branches,
so for now this change is reverted.  Additional regression tests will be
added on HEAD to track all the behaviors around parallel hints that have
been seen, while keeping the new plan changes only for 17~ and new major
release integration.

Per discussion on #164.

Backpatch-through: 13
  • Loading branch information
michaelpq committed Nov 7, 2023
1 parent 5f9f01c commit bfaabf1
Show file tree
Hide file tree
Showing 3 changed files with 107 additions and 158 deletions.
126 changes: 63 additions & 63 deletions expected/pg_hint_plan.out
Original file line number Diff line number Diff line change
Expand Up @@ -5571,15 +5571,15 @@ EXPLAIN (COSTS false) SELECT * FROM t5 WHERE t5.id = 1;
LOG: available indexes for IndexScan(t5):
LOG: pg_hint_plan:
used hint:
not used hint:
IndexScan(t5 no_exist)
not used hint:
duplication hint:
error hint:

QUERY PLAN
----------------------------------------------------------------------------------------
Index Scan using t5_idaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa on t5
Index Cond: (id = 1)
QUERY PLAN
--------------------
Seq Scan on t5
Filter: (id = 1)
(2 rows)

/*+IndexScan(t5 t5_id1 t5_id2)*/
Expand Down Expand Up @@ -5619,15 +5619,15 @@ EXPLAIN (COSTS false) SELECT * FROM t5 WHERE t5.id = 1;
LOG: available indexes for IndexScan(t5):
LOG: pg_hint_plan:
used hint:
not used hint:
IndexScan(t5 no_exist5 no_exist2)
not used hint:
duplication hint:
error hint:

QUERY PLAN
----------------------------------------------------------------------------------------
Index Scan using t5_idaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa on t5
Index Cond: (id = 1)
QUERY PLAN
--------------------
Seq Scan on t5
Filter: (id = 1)
(2 rows)

-- outer inner
Expand Down Expand Up @@ -6746,8 +6746,8 @@ LOG: available indexes for IndexScan(p2_c3_c1):
LOG: available indexes for IndexScan(p2_c3_c2):
LOG: pg_hint_plan:
used hint:
not used hint:
IndexScan(p2 p2_val)
not used hint:
duplication hint:
error hint:

Expand Down Expand Up @@ -6924,8 +6924,8 @@ LOG: available indexes for IndexScan(p2_c1_c1):
LOG: available indexes for IndexScan(p2_c1_c2):
LOG: pg_hint_plan:
used hint:
not used hint:
IndexScan(p2 no_exist)
not used hint:
duplication hint:
error hint:

Expand Down Expand Up @@ -7287,47 +7287,47 @@ EXPLAIN (COSTS false) SELECT id FROM t5 WHERE id = 1;
LOG: available indexes for IndexScanRegexp(t5):
LOG: pg_hint_plan:
used hint:
not used hint:
IndexScanRegexp(t5 t5[^_].*)
not used hint:
duplication hint:
error hint:

QUERY PLAN
---------------------------------------------------------------------------------------------
Index Only Scan using t5_idaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa on t5
Index Cond: (id = 1)
QUERY PLAN
--------------------
Seq Scan on t5
Filter: (id = 1)
(2 rows)

/*+ IndexScanRegexp(t5 ^.*t5_idaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab)*/
EXPLAIN (COSTS false) SELECT id FROM t5 WHERE id = 1;
LOG: available indexes for IndexScanRegexp(t5):
LOG: pg_hint_plan:
used hint:
not used hint:
IndexScanRegexp(t5 ^.*t5_idaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab)
not used hint:
duplication hint:
error hint:

QUERY PLAN
---------------------------------------------------------------------------------------------
Index Only Scan using t5_idaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa on t5
Index Cond: (id = 1)
QUERY PLAN
--------------------
Seq Scan on t5
Filter: (id = 1)
(2 rows)

/*+ IndexScan(t5 t5_id[0-9].*)*/
EXPLAIN (COSTS false) SELECT id FROM t5 WHERE id = 1;
LOG: available indexes for IndexScan(t5):
LOG: pg_hint_plan:
used hint:
not used hint:
IndexScan(t5 t5_id[0-9].*)
not used hint:
duplication hint:
error hint:

QUERY PLAN
---------------------------------------------------------------------------------------------
Index Only Scan using t5_idaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa on t5
Index Cond: (id = 1)
QUERY PLAN
--------------------
Seq Scan on t5
Filter: (id = 1)
(2 rows)

/*+ IndexOnlyScanRegexp(t5 t5_[^i].*)*/
Expand Down Expand Up @@ -7367,47 +7367,47 @@ EXPLAIN (COSTS false) SELECT id FROM t5 WHERE id = 1;
LOG: available indexes for IndexOnlyScanRegexp(t5):
LOG: pg_hint_plan:
used hint:
not used hint:
IndexOnlyScanRegexp(t5 t5[^_].*)
not used hint:
duplication hint:
error hint:

QUERY PLAN
---------------------------------------------------------------------------------------------
Index Only Scan using t5_idaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa on t5
Index Cond: (id = 1)
QUERY PLAN
--------------------
Seq Scan on t5
Filter: (id = 1)
(2 rows)

/*+ IndexOnlyScanRegexp(t5 ^.*t5_idaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab)*/
EXPLAIN (COSTS false) SELECT id FROM t5 WHERE id = 1;
LOG: available indexes for IndexOnlyScanRegexp(t5):
LOG: pg_hint_plan:
used hint:
not used hint:
IndexOnlyScanRegexp(t5 ^.*t5_idaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab)
not used hint:
duplication hint:
error hint:

QUERY PLAN
---------------------------------------------------------------------------------------------
Index Only Scan using t5_idaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa on t5
Index Cond: (id = 1)
QUERY PLAN
--------------------
Seq Scan on t5
Filter: (id = 1)
(2 rows)

/*+ IndexOnlyScan(t5 t5_id[0-9].*)*/
EXPLAIN (COSTS false) SELECT id FROM t5 WHERE id = 1;
LOG: available indexes for IndexOnlyScan(t5):
LOG: pg_hint_plan:
used hint:
not used hint:
IndexOnlyScan(t5 t5_id[0-9].*)
not used hint:
duplication hint:
error hint:

QUERY PLAN
---------------------------------------------------------------------------------------------
Index Only Scan using t5_idaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa on t5
Index Cond: (id = 1)
QUERY PLAN
--------------------
Seq Scan on t5
Filter: (id = 1)
(2 rows)

/*+ BitmapScanRegexp(t5 t5_[^i].*)*/
Expand Down Expand Up @@ -7451,47 +7451,47 @@ EXPLAIN (COSTS false) SELECT id FROM t5 WHERE id = 1;
LOG: available indexes for BitmapScanRegexp(t5):
LOG: pg_hint_plan:
used hint:
not used hint:
BitmapScanRegexp(t5 t5[^_].*)
not used hint:
duplication hint:
error hint:

QUERY PLAN
---------------------------------------------------------------------------------------------
Index Only Scan using t5_idaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa on t5
Index Cond: (id = 1)
QUERY PLAN
--------------------
Seq Scan on t5
Filter: (id = 1)
(2 rows)

/*+ BitmapScanRegexp(t5 ^.*t5_idaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab)*/
EXPLAIN (COSTS false) SELECT id FROM t5 WHERE id = 1;
LOG: available indexes for BitmapScanRegexp(t5):
LOG: pg_hint_plan:
used hint:
not used hint:
BitmapScanRegexp(t5 ^.*t5_idaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab)
not used hint:
duplication hint:
error hint:

QUERY PLAN
---------------------------------------------------------------------------------------------
Index Only Scan using t5_idaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa on t5
Index Cond: (id = 1)
QUERY PLAN
--------------------
Seq Scan on t5
Filter: (id = 1)
(2 rows)

/*+ BitmapScan(t5 t5_id[0-9].*)*/
EXPLAIN (COSTS false) SELECT id FROM t5 WHERE id = 1;
LOG: available indexes for BitmapScan(t5):
LOG: pg_hint_plan:
used hint:
not used hint:
BitmapScan(t5 t5_id[0-9].*)
not used hint:
duplication hint:
error hint:

QUERY PLAN
---------------------------------------------------------------------------------------------
Index Only Scan using t5_idaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa on t5
Index Cond: (id = 1)
QUERY PLAN
--------------------
Seq Scan on t5
Filter: (id = 1)
(2 rows)

-- Inheritance
Expand Down Expand Up @@ -7614,8 +7614,8 @@ LOG: available indexes for IndexScanRegexp(p1_c3_c1):
LOG: available indexes for IndexScanRegexp(p1_c3_c2):
LOG: pg_hint_plan:
used hint:
not used hint:
IndexScanRegexp(p1 p1[^_].*)
not used hint:
duplication hint:
error hint:

Expand Down Expand Up @@ -7655,8 +7655,8 @@ LOG: available indexes for IndexScan(p1_c3_c1):
LOG: available indexes for IndexScan(p1_c3_c2):
LOG: pg_hint_plan:
used hint:
not used hint:
IndexScan(p1 p1_.*val2.*)
not used hint:
duplication hint:
error hint:

Expand Down Expand Up @@ -7778,8 +7778,8 @@ LOG: available indexes for IndexOnlyScanRegexp(p1_c3_c1):
LOG: available indexes for IndexOnlyScanRegexp(p1_c3_c2):
LOG: pg_hint_plan:
used hint:
not used hint:
IndexOnlyScanRegexp(p1 p1[^_].*)
not used hint:
duplication hint:
error hint:

Expand Down Expand Up @@ -7819,8 +7819,8 @@ LOG: available indexes for IndexOnlyScan(p1_c3_c1):
LOG: available indexes for IndexOnlyScan(p1_c3_c2):
LOG: pg_hint_plan:
used hint:
not used hint:
IndexOnlyScan(p1 p1_.*val2.*)
not used hint:
duplication hint:
error hint:

Expand Down Expand Up @@ -7960,8 +7960,8 @@ LOG: available indexes for BitmapScanRegexp(p1_c3_c1):
LOG: available indexes for BitmapScanRegexp(p1_c3_c2):
LOG: pg_hint_plan:
used hint:
not used hint:
BitmapScanRegexp(p1 p1[^_].*)
not used hint:
duplication hint:
error hint:

Expand Down Expand Up @@ -8001,8 +8001,8 @@ LOG: available indexes for BitmapScan(p1_c3_c1):
LOG: available indexes for BitmapScan(p1_c3_c2):
LOG: pg_hint_plan:
used hint:
not used hint:
BitmapScan(p1 p1_.*val2.*)
not used hint:
duplication hint:
error hint:

Expand Down
Loading

0 comments on commit bfaabf1

Please sign in to comment.