mirror of
https://github.com/postgres/postgres.git
synced 2025-07-02 09:02:37 +03:00
Fix handling of "Subplans Removed" field in EXPLAIN output.
Commit 499be013d
added this field in a rather poorly-thought-through
manner, with the result being that rather than being a field of the
Append or MergeAppend plan node as intended (and as it seems to be,
in text format), it was actually an element of the "Plans" subgroup.
At least in JSON format, that's flat out invalid syntax, because
"Plans" is an array not an object.
While it's not hard to move the generation of the field so that it
appears where it's supposed to, this does result in a visible change
in field order in text format, in cases where a Append or MergeAppend
plan node has any InitPlans attached. That's slightly annoying to
do in stable branches; but the alternative of continuing to emit
broken non-text formats seems worse.
Also, since the set of fields emitted is not supposed to be
data-dependent in non-text formats, make sure that "Subplans Removed"
appears in Append and MergeAppend nodes even when it's zero, in those
formats. (The previous coding made it look like it could appear in
some other node types such as BitmapAnd, but we don't actually support
runtime pruning there, so don't emit it in those cases.)
Per bug #16171 from Mahadevan Ramachandran. Fix by Daniel Gustafsson
and Tom Lane, reviewed by Hamid Akhtar. Back-patch to v11 where this
code came in.
Discussion: https://postgr.es/m/16171-b72259ab75505fa2@postgresql.org
This commit is contained in:
@ -1846,9 +1846,9 @@ explain (analyze, costs off, summary off, timing off) execute ab_q2 (2, 2);
|
||||
QUERY PLAN
|
||||
--------------------------------------------------------
|
||||
Append (actual rows=0 loops=1)
|
||||
Subplans Removed: 6
|
||||
InitPlan 1 (returns $0)
|
||||
-> Result (actual rows=1 loops=1)
|
||||
Subplans Removed: 6
|
||||
-> Seq Scan on ab_a2_b1 (actual rows=0 loops=1)
|
||||
Filter: ((a >= $1) AND (a <= $2) AND (b < $0))
|
||||
-> Seq Scan on ab_a2_b2 (actual rows=0 loops=1)
|
||||
@ -1889,9 +1889,9 @@ explain (analyze, costs off, summary off, timing off) execute ab_q3 (2, 2);
|
||||
QUERY PLAN
|
||||
--------------------------------------------------------
|
||||
Append (actual rows=0 loops=1)
|
||||
Subplans Removed: 6
|
||||
InitPlan 1 (returns $0)
|
||||
-> Result (actual rows=1 loops=1)
|
||||
Subplans Removed: 6
|
||||
-> Seq Scan on ab_a1_b2 (actual rows=0 loops=1)
|
||||
Filter: ((b >= $1) AND (b <= $2) AND (a < $0))
|
||||
-> Seq Scan on ab_a2_b2 (actual rows=0 loops=1)
|
||||
@ -2527,9 +2527,9 @@ explain (analyze, costs off, summary off, timing off) execute ab_q6(1);
|
||||
QUERY PLAN
|
||||
--------------------------------------------------------
|
||||
Append (actual rows=0 loops=1)
|
||||
Subplans Removed: 12
|
||||
InitPlan 1 (returns $0)
|
||||
-> Result (actual rows=1 loops=1)
|
||||
Subplans Removed: 12
|
||||
-> Seq Scan on ab_a1_b1 (never executed)
|
||||
Filter: ((a = $1) AND (b = $0))
|
||||
-> Seq Scan on ab_a1_b2 (never executed)
|
||||
@ -3250,9 +3250,9 @@ execute ps1(1);
|
||||
QUERY PLAN
|
||||
-------------------------------------------------
|
||||
Append (actual rows=1 loops=1)
|
||||
Subplans Removed: 2
|
||||
InitPlan 1 (returns $0)
|
||||
-> Result (actual rows=1 loops=1)
|
||||
Subplans Removed: 2
|
||||
-> Seq Scan on mc3p1 (actual rows=1 loops=1)
|
||||
Filter: ((a = $1) AND (abs(b) < $0))
|
||||
(6 rows)
|
||||
@ -3265,9 +3265,9 @@ execute ps2(1);
|
||||
QUERY PLAN
|
||||
-------------------------------------------------
|
||||
Append (actual rows=2 loops=1)
|
||||
Subplans Removed: 1
|
||||
InitPlan 1 (returns $0)
|
||||
-> Result (actual rows=1 loops=1)
|
||||
Subplans Removed: 1
|
||||
-> Seq Scan on mc3p0 (actual rows=1 loops=1)
|
||||
Filter: ((a <= $1) AND (abs(b) < $0))
|
||||
-> Seq Scan on mc3p1 (actual rows=1 loops=1)
|
||||
@ -3845,9 +3845,9 @@ explain (costs off) execute q (1, 1);
|
||||
QUERY PLAN
|
||||
---------------------------------------------------------------
|
||||
Append
|
||||
Subplans Removed: 1
|
||||
InitPlan 1 (returns $0)
|
||||
-> Result
|
||||
Subplans Removed: 1
|
||||
-> Seq Scan on p1
|
||||
Filter: ((a = $1) AND (b = $2) AND (c = $0))
|
||||
-> Seq Scan on q111
|
||||
|
Reference in New Issue
Block a user