Skip to content

Commit 952b280

Browse files
committed
Fix force_parallel_mode to work as intended.
The force_parallel_mode GUC is meant to facilitate testing of parallel query plans, but it currently allows non-parallel plans to win even when force_parallel_mode is enabled. This behavior makes it difficult to debug parallel plans as intended. Correct the behavior for testing purposes. Authored-by: Zhang Mingli [email protected]
1 parent 793971e commit 952b280

File tree

4 files changed

+8
-6
lines changed

4 files changed

+8
-6
lines changed

src/backend/optimizer/plan/planner.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -593,6 +593,8 @@ standard_planner(Query *parse, const char *query_string, int cursorOptions,
593593
{
594594
Path *cheapest_partial_path;
595595
cheapest_partial_path = linitial(final_rel->partial_pathlist);
596+
if (force_parallel_mode == FORCE_PARALLEL_ON)
597+
final_rel->pathlist = NIL;
596598
add_path(final_rel, cheapest_partial_path, root);
597599
set_cheapest(final_rel);
598600
}

src/test/regress/expected/incremental_sort.out

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,6 @@ select explain_analyze_without_memory('select * from (select * from t order by a
589589
Optimizer: Postgres query optimizer
590590
(13 rows)
591591

592-
reset max_parallel_workers_per_gather;
593592
select jsonb_pretty(explain_analyze_inc_sort_nodes_without_memory('select * from (select * from t order by a) s order by a, b limit 55'));
594593
jsonb_pretty
595594
-------------------------------------------------
@@ -626,6 +625,7 @@ select jsonb_pretty(explain_analyze_inc_sort_nodes_without_memory('select * from
626625
]
627626
(1 row)
628627

628+
reset max_parallel_workers_per_gather;
629629
select explain_analyze_inc_sort_nodes_verify_invariants('select * from (select * from t order by a) s order by a, b limit 55');
630630
explain_analyze_inc_sort_nodes_verify_invariants
631631
--------------------------------------------------
@@ -815,7 +815,6 @@ select explain_analyze_without_memory('select * from (select * from t order by a
815815
Optimizer: Postgres query optimizer
816816
(14 rows)
817817

818-
reset max_parallel_workers_per_gather;
819818
select jsonb_pretty(explain_analyze_inc_sort_nodes_without_memory('select * from (select * from t order by a) s order by a, b limit 70'));
820819
jsonb_pretty
821820
-------------------------------------------------
@@ -861,6 +860,7 @@ select jsonb_pretty(explain_analyze_inc_sort_nodes_without_memory('select * from
861860
]
862861
(1 row)
863862

863+
reset max_parallel_workers_per_gather;
864864
select explain_analyze_inc_sort_nodes_verify_invariants('select * from (select * from t order by a) s order by a, b limit 70');
865865
explain_analyze_inc_sort_nodes_verify_invariants
866866
--------------------------------------------------

src/test/regress/expected/incremental_sort_optimizer.out

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -560,14 +560,14 @@ select explain_analyze_without_memory('select * from (select * from t order by a
560560
Optimizer: Pivotal Optimizer (GPORCA)
561561
(9 rows)
562562

563-
reset max_parallel_workers_per_gather;
564563
select jsonb_pretty(explain_analyze_inc_sort_nodes_without_memory('select * from (select * from t order by a) s order by a, b limit 55'));
565564
jsonb_pretty
566565
--------------
567566
[ +
568567
]
569568
(1 row)
570569

570+
reset max_parallel_workers_per_gather;
571571
select explain_analyze_inc_sort_nodes_verify_invariants('select * from (select * from t order by a) s order by a, b limit 55');
572572
explain_analyze_inc_sort_nodes_verify_invariants
573573
--------------------------------------------------
@@ -743,14 +743,14 @@ select explain_analyze_without_memory('select * from (select * from t order by a
743743
Optimizer: Pivotal Optimizer (GPORCA)
744744
(10 rows)
745745

746-
reset max_parallel_workers_per_gather;
747746
select jsonb_pretty(explain_analyze_inc_sort_nodes_without_memory('select * from (select * from t order by a) s order by a, b limit 70'));
748747
jsonb_pretty
749748
--------------
750749
[ +
751750
]
752751
(1 row)
753752

753+
reset max_parallel_workers_per_gather;
754754
select explain_analyze_inc_sort_nodes_verify_invariants('select * from (select * from t order by a) s order by a, b limit 70');
755755
explain_analyze_inc_sort_nodes_verify_invariants
756756
--------------------------------------------------

src/test/regress/sql/incremental_sort.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,8 @@ select * from (select * from t order by a) s order by a, b limit 55;
147147
-- Test EXPLAIN ANALYZE with only a fullsort group.
148148
set max_parallel_workers_per_gather = 0;
149149
select explain_analyze_without_memory('select * from (select * from t order by a) s order by a, b limit 55');
150-
reset max_parallel_workers_per_gather;
151150
select jsonb_pretty(explain_analyze_inc_sort_nodes_without_memory('select * from (select * from t order by a) s order by a, b limit 55'));
151+
reset max_parallel_workers_per_gather;
152152
select explain_analyze_inc_sort_nodes_verify_invariants('select * from (select * from t order by a) s order by a, b limit 55');
153153
delete from t;
154154

@@ -181,8 +181,8 @@ rollback;
181181
-- Test EXPLAIN ANALYZE with both fullsort and presorted groups.
182182
set max_parallel_workers_per_gather = 0;
183183
select explain_analyze_without_memory('select * from (select * from t order by a) s order by a, b limit 70');
184-
reset max_parallel_workers_per_gather;
185184
select jsonb_pretty(explain_analyze_inc_sort_nodes_without_memory('select * from (select * from t order by a) s order by a, b limit 70'));
185+
reset max_parallel_workers_per_gather;
186186
select explain_analyze_inc_sort_nodes_verify_invariants('select * from (select * from t order by a) s order by a, b limit 70');
187187
delete from t;
188188

0 commit comments

Comments
 (0)