no-loop-division.patch
application/octet-stream
Filename: no-loop-division.patch
Type: application/octet-stream
Part: 0
Patch
Format: unified
| File | + | − |
|---|---|---|
| doc/src/sgml/perform.sgml | 1 | 1 |
| src/backend/commands/explain.c | 7 | 14 |
| src/test/regress/expected/partition_prune.out | 27 | 27 |
| src/test/regress/expected/select_parallel.out | 13 | 13 |
diff --git a/doc/src/sgml/perform.sgml b/doc/src/sgml/perform.sgml
index b50357c3b4..70e65549ac 100644
--- a/doc/src/sgml/perform.sgml
+++ b/doc/src/sgml/perform.sgml
@@ -562,7 +562,7 @@ WHERE t1.unique1 < 10 AND t1.unique2 = t2.unique2;
Recheck Cond: (unique1 < 10)
-> Bitmap Index Scan on tenk1_unique1 (cost=0.00..4.36 rows=10 width=0) (actual time=0.024..0.024 rows=10 loops=1)
Index Cond: (unique1 < 10)
- -> Index Scan using tenk2_unique2 on tenk2 t2 (cost=0.29..7.91 rows=1 width=244) (actual time=0.021..0.022 rows=1 loops=10)
+ -> Index Scan using tenk2_unique2 on tenk2 t2 (cost=0.29..7.91 rows=1 width=244) (actual time=0.021..0.220 rows=1 loops=10)
Index Cond: (unique2 = t1.unique2)
Planning time: 0.181 ms
Execution time: 0.501 ms
diff --git a/src/backend/commands/explain.c b/src/backend/commands/explain.c
index e1a62a1bce..a9c7f598af 100644
--- a/src/backend/commands/explain.c
+++ b/src/backend/commands/explain.c
@@ -1358,9 +1358,9 @@ ExplainNode(PlanState *planstate, List *ancestors,
planstate->instrument && planstate->instrument->nloops > 0)
{
double nloops = planstate->instrument->nloops;
- double startup_ms = 1000.0 * planstate->instrument->startup / nloops;
- double total_ms = 1000.0 * planstate->instrument->total / nloops;
- double rows = planstate->instrument->ntuples / nloops;
+ double startup_ms = 1000.0 * planstate->instrument->startup;
+ double total_ms = 1000.0 * planstate->instrument->total;
+ double rows = planstate->instrument->ntuples;
if (es->format == EXPLAIN_FORMAT_TEXT)
{
@@ -1714,9 +1714,9 @@ ExplainNode(PlanState *planstate, List *ancestors,
if (nloops <= 0)
continue;
- startup_ms = 1000.0 * instrument->startup / nloops;
- total_ms = 1000.0 * instrument->total / nloops;
- rows = instrument->ntuples / nloops;
+ startup_ms = 1000.0 * instrument->startup;
+ total_ms = 1000.0 * instrument->total;
+ rows = instrument->ntuples;
if (es->format == EXPLAIN_FORMAT_TEXT)
{
@@ -2580,7 +2580,6 @@ show_instrumentation_count(const char *qlabel, int which,
PlanState *planstate, ExplainState *es)
{
double nfiltered;
- double nloops;
if (!es->analyze || !planstate->instrument)
return;
@@ -2589,16 +2588,10 @@ show_instrumentation_count(const char *qlabel, int which,
nfiltered = planstate->instrument->nfiltered2;
else
nfiltered = planstate->instrument->nfiltered1;
- nloops = planstate->instrument->nloops;
/* In text mode, suppress zero counts; they're not interesting enough */
if (nfiltered > 0 || es->format != EXPLAIN_FORMAT_TEXT)
- {
- if (nloops > 0)
- ExplainPropertyFloat(qlabel, NULL, nfiltered / nloops, 0, es);
- else
- ExplainPropertyFloat(qlabel, NULL, 0.0, 0, es);
- }
+ ExplainPropertyFloat(qlabel, NULL, nfiltered, 0, es);
}
/*
diff --git a/src/test/regress/expected/partition_prune.out b/src/test/regress/expected/partition_prune.out
index e0cc5f3393..06331d19c5 100644
--- a/src/test/regress/expected/partition_prune.out
+++ b/src/test/regress/expected/partition_prune.out
@@ -1837,7 +1837,7 @@ select explain_parallel_append('execute ab_q4 (2, 2)');
-> Gather (actual rows=3 loops=1)
Workers Planned: 2
Workers Launched: 2
- -> Partial Aggregate (actual rows=1 loops=3)
+ -> Partial Aggregate (actual rows=3 loops=3)
-> Parallel Append (actual rows=0 loops=N)
Subplans Removed: 6
-> Parallel Seq Scan on ab_a2_b1 (actual rows=0 loops=N)
@@ -1890,7 +1890,7 @@ select explain_parallel_append('execute ab_q5 (1, 1, 1)');
-> Gather (actual rows=3 loops=1)
Workers Planned: 2
Workers Launched: 2
- -> Partial Aggregate (actual rows=1 loops=3)
+ -> Partial Aggregate (actual rows=3 loops=3)
-> Parallel Append (actual rows=0 loops=N)
Subplans Removed: 6
-> Parallel Seq Scan on ab_a1_b1 (actual rows=0 loops=N)
@@ -1908,7 +1908,7 @@ select explain_parallel_append('execute ab_q5 (2, 3, 3)');
-> Gather (actual rows=3 loops=1)
Workers Planned: 2
Workers Launched: 2
- -> Partial Aggregate (actual rows=1 loops=3)
+ -> Partial Aggregate (actual rows=3 loops=3)
-> Parallel Append (actual rows=0 loops=N)
Subplans Removed: 3
-> Parallel Seq Scan on ab_a2_b1 (actual rows=0 loops=N)
@@ -1934,7 +1934,7 @@ select explain_parallel_append('execute ab_q5 (33, 44, 55)');
-> Gather (actual rows=3 loops=1)
Workers Planned: 2
Workers Launched: 2
- -> Partial Aggregate (actual rows=1 loops=3)
+ -> Partial Aggregate (actual rows=3 loops=3)
-> Parallel Append (actual rows=0 loops=N)
Subplans Removed: 8
-> Parallel Seq Scan on ab_a1_b1 (never executed)
@@ -1988,9 +1988,9 @@ select explain_parallel_append('select avg(ab.a) from ab inner join lprt_a a on
-> Gather (actual rows=2 loops=1)
Workers Planned: 1
Workers Launched: 1
- -> Partial Aggregate (actual rows=1 loops=2)
+ -> Partial Aggregate (actual rows=2 loops=2)
-> Nested Loop (actual rows=0 loops=2)
- -> Parallel Seq Scan on lprt_a a (actual rows=51 loops=N)
+ -> Parallel Seq Scan on lprt_a a (actual rows=102 loops=N)
Filter: (a = ANY ('{0,0,1}'::integer[]))
-> Append (actual rows=0 loops=102)
-> Index Scan using ab_a1_b1_a_idx on ab_a1_b1 (actual rows=0 loops=2)
@@ -2021,9 +2021,9 @@ select explain_parallel_append('select avg(ab.a) from ab inner join lprt_a a on
-> Gather (actual rows=2 loops=1)
Workers Planned: 1
Workers Launched: 1
- -> Partial Aggregate (actual rows=1 loops=2)
+ -> Partial Aggregate (actual rows=2 loops=2)
-> Nested Loop (actual rows=0 loops=2)
- -> Parallel Seq Scan on lprt_a a (actual rows=52 loops=N)
+ -> Parallel Seq Scan on lprt_a a (actual rows=104 loops=N)
Filter: (a = ANY ('{1,0,3}'::integer[]))
-> Append (actual rows=0 loops=104)
-> Index Scan using ab_a1_b1_a_idx on ab_a1_b1 (actual rows=0 loops=2)
@@ -2053,11 +2053,11 @@ select explain_parallel_append('select avg(ab.a) from ab inner join lprt_a a on
-> Gather (actual rows=2 loops=1)
Workers Planned: 1
Workers Launched: 1
- -> Partial Aggregate (actual rows=1 loops=2)
+ -> Partial Aggregate (actual rows=2 loops=2)
-> Nested Loop (actual rows=0 loops=2)
- -> Parallel Seq Scan on lprt_a a (actual rows=51 loops=N)
+ -> Parallel Seq Scan on lprt_a a (actual rows=102 loops=N)
Filter: (a = ANY ('{1,0,0}'::integer[]))
- Rows Removed by Filter: 1
+ Rows Removed by Filter: 2
-> Append (actual rows=0 loops=102)
-> Index Scan using ab_a1_b1_a_idx on ab_a1_b1 (actual rows=0 loops=2)
Index Cond: (a = a.a)
@@ -2087,11 +2087,11 @@ select explain_parallel_append('select avg(ab.a) from ab inner join lprt_a a on
-> Gather (actual rows=2 loops=1)
Workers Planned: 1
Workers Launched: 1
- -> Partial Aggregate (actual rows=1 loops=2)
+ -> Partial Aggregate (actual rows=2 loops=2)
-> Nested Loop (actual rows=0 loops=2)
- -> Parallel Seq Scan on lprt_a a (actual rows=50 loops=N)
+ -> Parallel Seq Scan on lprt_a a (actual rows=100 loops=N)
Filter: (a = ANY ('{1,0,0}'::integer[]))
- Rows Removed by Filter: 1
+ Rows Removed by Filter: 2
-> Append (actual rows=0 loops=100)
-> Index Scan using ab_a1_b1_a_idx on ab_a1_b1 (never executed)
Index Cond: (a = a.a)
@@ -2210,8 +2210,8 @@ select * from tbl1 join tprt on tbl1.col1 > tprt.col1;
--------------------------------------------------------------------------
Nested Loop (actual rows=6 loops=1)
-> Seq Scan on tbl1 (actual rows=2 loops=1)
- -> Append (actual rows=3 loops=2)
- -> Index Scan using tprt1_idx on tprt_1 (actual rows=2 loops=2)
+ -> Append (actual rows=6 loops=2)
+ -> Index Scan using tprt1_idx on tprt_1 (actual rows=4 loops=2)
Index Cond: (tbl1.col1 > col1)
-> Index Scan using tprt2_idx on tprt_2 (actual rows=2 loops=1)
Index Cond: (tbl1.col1 > col1)
@@ -2231,10 +2231,10 @@ select * from tbl1 join tprt on tbl1.col1 = tprt.col1;
--------------------------------------------------------------------------
Nested Loop (actual rows=2 loops=1)
-> Seq Scan on tbl1 (actual rows=2 loops=1)
- -> Append (actual rows=1 loops=2)
+ -> Append (actual rows=2 loops=2)
-> Index Scan using tprt1_idx on tprt_1 (never executed)
Index Cond: (col1 = tbl1.col1)
- -> Index Scan using tprt2_idx on tprt_2 (actual rows=1 loops=2)
+ -> Index Scan using tprt2_idx on tprt_2 (actual rows=2 loops=2)
Index Cond: (col1 = tbl1.col1)
-> Index Scan using tprt3_idx on tprt_3 (never executed)
Index Cond: (col1 = tbl1.col1)
@@ -2272,16 +2272,16 @@ order by tbl1.col1, tprt.col1;
insert into tbl1 values (1001), (1010), (1011);
explain (analyze, costs off, summary off, timing off)
select * from tbl1 inner join tprt on tbl1.col1 > tprt.col1;
- QUERY PLAN
---------------------------------------------------------------------------
+ QUERY PLAN
+---------------------------------------------------------------------------
Nested Loop (actual rows=23 loops=1)
-> Seq Scan on tbl1 (actual rows=5 loops=1)
- -> Append (actual rows=5 loops=5)
- -> Index Scan using tprt1_idx on tprt_1 (actual rows=2 loops=5)
+ -> Append (actual rows=23 loops=5)
+ -> Index Scan using tprt1_idx on tprt_1 (actual rows=10 loops=5)
Index Cond: (tbl1.col1 > col1)
- -> Index Scan using tprt2_idx on tprt_2 (actual rows=3 loops=4)
+ -> Index Scan using tprt2_idx on tprt_2 (actual rows=11 loops=4)
Index Cond: (tbl1.col1 > col1)
- -> Index Scan using tprt3_idx on tprt_3 (actual rows=1 loops=2)
+ -> Index Scan using tprt3_idx on tprt_3 (actual rows=2 loops=2)
Index Cond: (tbl1.col1 > col1)
-> Index Scan using tprt4_idx on tprt_4 (never executed)
Index Cond: (tbl1.col1 > col1)
@@ -2297,12 +2297,12 @@ select * from tbl1 inner join tprt on tbl1.col1 = tprt.col1;
--------------------------------------------------------------------------
Nested Loop (actual rows=3 loops=1)
-> Seq Scan on tbl1 (actual rows=5 loops=1)
- -> Append (actual rows=1 loops=5)
+ -> Append (actual rows=3 loops=5)
-> Index Scan using tprt1_idx on tprt_1 (never executed)
Index Cond: (col1 = tbl1.col1)
- -> Index Scan using tprt2_idx on tprt_2 (actual rows=1 loops=2)
+ -> Index Scan using tprt2_idx on tprt_2 (actual rows=2 loops=2)
Index Cond: (col1 = tbl1.col1)
- -> Index Scan using tprt3_idx on tprt_3 (actual rows=0 loops=3)
+ -> Index Scan using tprt3_idx on tprt_3 (actual rows=1 loops=3)
Index Cond: (col1 = tbl1.col1)
-> Index Scan using tprt4_idx on tprt_4 (never executed)
Index Cond: (col1 = tbl1.col1)
diff --git a/src/test/regress/expected/select_parallel.out b/src/test/regress/expected/select_parallel.out
index a07cd50fcb..c7d80927da 100644
--- a/src/test/regress/expected/select_parallel.out
+++ b/src/test/regress/expected/select_parallel.out
@@ -482,19 +482,19 @@ alter table tenk2 set (parallel_workers = 0);
explain (analyze, timing off, summary off, costs off)
select count(*) from tenk1, tenk2 where tenk1.hundred > 1
and tenk2.thousand=0;
- QUERY PLAN
---------------------------------------------------------------------------
+ QUERY PLAN
+---------------------------------------------------------------------------
Aggregate (actual rows=1 loops=1)
-> Nested Loop (actual rows=98000 loops=1)
-> Seq Scan on tenk2 (actual rows=10 loops=1)
Filter: (thousand = 0)
Rows Removed by Filter: 9990
- -> Gather (actual rows=9800 loops=10)
+ -> Gather (actual rows=98000 loops=10)
Workers Planned: 4
Workers Launched: 4
- -> Parallel Seq Scan on tenk1 (actual rows=1960 loops=50)
+ -> Parallel Seq Scan on tenk1 (actual rows=98000 loops=50)
Filter: (hundred > 1)
- Rows Removed by Filter: 40
+ Rows Removed by Filter: 2000
(11 rows)
alter table tenk2 reset (parallel_workers);
@@ -516,21 +516,21 @@ begin
end;
$$;
select * from explain_parallel_sort_stats();
- explain_parallel_sort_stats
---------------------------------------------------------------------------
+ explain_parallel_sort_stats
+---------------------------------------------------------------------------
Nested Loop Left Join (actual rows=30000 loops=1)
-> Values Scan on "*VALUES*" (actual rows=3 loops=1)
- -> Gather Merge (actual rows=10000 loops=3)
+ -> Gather Merge (actual rows=30000 loops=3)
Workers Planned: 4
Workers Launched: 4
- -> Sort (actual rows=2000 loops=15)
+ -> Sort (actual rows=30000 loops=15)
Sort Key: tenk1.ten
Sort Method: quicksort Memory: xxx
Worker 0: Sort Method: quicksort Memory: xxx
Worker 1: Sort Method: quicksort Memory: xxx
Worker 2: Sort Method: quicksort Memory: xxx
Worker 3: Sort Method: quicksort Memory: xxx
- -> Parallel Seq Scan on tenk1 (actual rows=2000 loops=15)
+ -> Parallel Seq Scan on tenk1 (actual rows=30000 loops=15)
Filter: (ten < 100)
(14 rows)
@@ -874,12 +874,12 @@ reset role;
SAVEPOINT settings;
SET LOCAL force_parallel_mode = 1;
EXPLAIN (analyze, timing off, summary off, costs off) SELECT * FROM tenk1;
- QUERY PLAN
--------------------------------------------------------------
+ QUERY PLAN
+--------------------------------------------------------------
Gather (actual rows=10000 loops=1)
Workers Planned: 4
Workers Launched: 4
- -> Parallel Seq Scan on tenk1 (actual rows=2000 loops=5)
+ -> Parallel Seq Scan on tenk1 (actual rows=10000 loops=5)
(4 rows)
ROLLBACK TO SAVEPOINT settings;