if (es->format == EXPLAIN_FORMAT_TEXT)
appendStringInfoChar(es->str, '\n');
+ if (plan->disabled_nodes != 0)
+ ExplainPropertyInteger("Disabled Nodes", NULL, plan->disabled_nodes,
+ es);
+
/* prepare per-worker general execution details */
if (es->workers_state && es->verbose)
{
0, NULL, NULL, NULL);
/* Must apply correct cost/width data to Limit node */
+ plan->disabled_nodes = mminfo->path->disabled_nodes;
plan->startup_cost = mminfo->path->startup_cost;
plan->total_cost = mminfo->pathcost;
plan->plan_rows = 1;
static void
copy_generic_path_info(Plan *dest, Path *src)
{
+ dest->disabled_nodes = src->disabled_nodes;
dest->startup_cost = src->startup_cost;
dest->total_cost = src->total_cost;
dest->plan_rows = src->rows;
static void
copy_plan_costsize(Plan *dest, Plan *src)
{
+ dest->disabled_nodes = src->disabled_nodes;
dest->startup_cost = src->startup_cost;
dest->total_cost = src->total_cost;
dest->plan_rows = src->plan_rows;
cost_sort(&sort_path, root, NIL,
lefttree->total_cost,
- 0, /* a Plan contains no count of disabled nodes */
+ plan->plan.disabled_nodes,
lefttree->plan_rows,
lefttree->plan_width,
0.0,
/* Set cost data */
cost_material(&matpath,
- 0, /* a Plan contains no count of disabled nodes */
+ subplan->disabled_nodes,
subplan->startup_cost,
subplan->total_cost,
subplan->plan_rows,
subplan->plan_width);
+ matplan->disabled_nodes = subplan->disabled_nodes;
matplan->startup_cost = matpath.startup_cost + initplan_cost;
matplan->total_cost = matpath.total_cost + initplan_cost;
matplan->plan_rows = subplan->plan_rows;
/*
* estimated execution costs for plan (see costsize.c for more info)
*/
+ int disabled_nodes; /* count of disabled nodes */
Cost startup_cost; /* cost expended before fetching any tuples */
Cost total_cost; /* total cost (assuming all tuples fetched) */
QUERY PLAN
-----------------------------------------------------
GroupAggregate
+ Disabled Nodes: 2
Group Key: c1.w, c1.z
-> Sort
+ Disabled Nodes: 2
Sort Key: c1.w, c1.z, c1.x, c1.y
-> Merge Join
+ Disabled Nodes: 2
Merge Cond: (c1.x = c2.x)
-> Sort
Sort Key: c1.x
-> Seq Scan on group_agg_pk c1
+ Disabled Nodes: 1
-> Sort
Sort Key: c2.x
-> Seq Scan on group_agg_pk c2
-(12 rows)
+ Disabled Nodes: 1
+(17 rows)
SELECT avg(c1.f ORDER BY c1.x, c1.y)
FROM group_agg_pk c1 JOIN group_agg_pk c2 ON c1.x = c2.x
QUERY PLAN
-----------------------------------------------------
Group
+ Disabled Nodes: 2
Group Key: c1.x, c1.y
-> Incremental Sort
+ Disabled Nodes: 2
Sort Key: c1.x, c1.y
Presorted Key: c1.x
-> Merge Join
+ Disabled Nodes: 2
Merge Cond: (c1.x = c2.x)
-> Sort
Sort Key: c1.x
-> Seq Scan on group_agg_pk c1
+ Disabled Nodes: 1
-> Sort
Sort Key: c2.x
-> Seq Scan on group_agg_pk c2
-(13 rows)
+ Disabled Nodes: 1
+(18 rows)
EXPLAIN (COSTS OFF)
SELECT c1.y,c1.x FROM group_agg_pk c1
QUERY PLAN
-----------------------------------------------------
Group
+ Disabled Nodes: 2
Group Key: c2.x, c1.y
-> Incremental Sort
+ Disabled Nodes: 2
Sort Key: c2.x, c1.y
Presorted Key: c2.x
-> Merge Join
+ Disabled Nodes: 2
Merge Cond: (c1.x = c2.x)
-> Sort
Sort Key: c1.x
-> Seq Scan on group_agg_pk c1
+ Disabled Nodes: 1
-> Sort
Sort Key: c2.x
-> Seq Scan on group_agg_pk c2
-(13 rows)
+ Disabled Nodes: 1
+(18 rows)
RESET enable_nestloop;
RESET enable_hashjoin;
QUERY PLAN
----------------------------------------------
Sort
+ Disabled Nodes: 1
Sort Key: proname
-> Seq Scan on pg_proc
+ Disabled Nodes: 1
Filter: (proname ~~* 'ri%foo'::text)
-(4 rows)
+(6 rows)
reset enable_seqscan;
reset enable_indexscan;
QUERY PLAN
-------------------------------
Seq Scan on collate_test1
+ Disabled Nodes: 1
Filter: (b ~~* 'abc'::text)
-(2 rows)
+(3 rows)
select * from collate_test1 where b ilike 'abc';
a | b
QUERY PLAN
-------------------------------
Seq Scan on collate_test1
+ Disabled Nodes: 1
Filter: (b ~~* 'ABC'::text)
-(2 rows)
+(3 rows)
select * from collate_test1 where b ilike 'ABC';
a | b
QUERY PLAN
------------------------------------------------
Nested Loop Left Join
+ Disabled Nodes: 1
Join Filter: (t_1.a = t.a)
-> Seq Scan on t
Filter: (a = ANY ('{1,2}'::integer[]))
-> Incremental Sort
+ Disabled Nodes: 1
Sort Key: t_1.a, t_1.b
Presorted Key: t_1.a
-> Sort
+ Disabled Nodes: 1
Sort Key: t_1.a
-> Seq Scan on t t_1
-(10 rows)
+(13 rows)
select * from t left join (select * from (select * from t order by a) v order by a, b) s on s.a = t.a where t.a in (1, 2);
a | b | a | b
QUERY PLAN
------------------------------------------------------------------------
Merge Append
+ Disabled Nodes: 1
Sort Key: ((1 - matest0.id))
-> Index Scan using matest0i on public.matest0 matest0_1
Output: matest0_1.id, matest0_1.name, (1 - matest0_1.id)
Output: matest0_3.id, matest0_3.name, ((1 - matest0_3.id))
Sort Key: ((1 - matest0_3.id))
-> Seq Scan on public.matest2 matest0_3
+ Disabled Nodes: 1
Output: matest0_3.id, matest0_3.name, (1 - matest0_3.id)
-> Index Scan using matest3i on public.matest3 matest0_4
Output: matest0_4.id, matest0_4.name, (1 - matest0_4.id)
-(13 rows)
+(15 rows)
select * from matest0 order by 1-id;
id | name
QUERY PLAN
---------------------------------------------------------
Nested Loop Anti Join
+ Disabled Nodes: 1
-> Seq Scan on skip_fetch t1
+ Disabled Nodes: 1
-> Materialize
-> Bitmap Heap Scan on skip_fetch t2
Recheck Cond: (a = 1)
-> Bitmap Index Scan on skip_fetch_a_idx
Index Cond: (a = 1)
-(7 rows)
+(9 rows)
SELECT t1.a FROM skip_fetch t1 LEFT JOIN skip_fetch t2 ON t2.a = 1 WHERE t2.a IS NULL;
a
explain_memoize
----------------------------------------------------------------------------------
Nested Loop (actual rows=24 loops=N)
+ Disabled Nodes: 1
-> Seq Scan on strtest s1 (actual rows=6 loops=N)
+ Disabled Nodes: 1
-> Memoize (actual rows=4 loops=N)
Cache Key: s1.n
Cache Mode: binary
Hits: 3 Misses: 3 Evictions: Zero Overflows: 0 Memory Usage: NkB
-> Index Scan using strtest_n_idx on strtest s2 (actual rows=4 loops=N)
Index Cond: (n <= s1.n)
-(8 rows)
+(10 rows)
-- Ensure we get 3 hits and 3 misses
SELECT explain_memoize('
explain_memoize
----------------------------------------------------------------------------------
Nested Loop (actual rows=24 loops=N)
+ Disabled Nodes: 1
-> Seq Scan on strtest s1 (actual rows=6 loops=N)
+ Disabled Nodes: 1
-> Memoize (actual rows=4 loops=N)
Cache Key: s1.t
Cache Mode: binary
Hits: 3 Misses: 3 Evictions: Zero Overflows: 0 Memory Usage: NkB
-> Index Scan using strtest_t_idx on strtest s2 (actual rows=4 loops=N)
Index Cond: (t <= s1.t)
-(8 rows)
+(10 rows)
DROP TABLE strtest;
-- Ensure memoize works with partitionwise join
QUERY PLAN
------------------------------------------------------------
Aggregate
+ Disabled Nodes: 1
-> Nested Loop
+ Disabled Nodes: 1
-> Gather
+ Disabled Nodes: 1
Workers Planned: 4
-> Parallel Seq Scan on tenk2
+ Disabled Nodes: 1
Filter: (thousand = 0)
-> Gather
Workers Planned: 4
Recheck Cond: (hundred > 1)
-> Bitmap Index Scan on tenk1_hundred
Index Cond: (hundred > 1)
-(12 rows)
+(16 rows)
select count(*) from tenk1, tenk2 where tenk1.hundred > 1 and tenk2.thousand=0;
count
QUERY PLAN
---------------------------
HashAggregate
+ Disabled Nodes: 1
Group Key: ('123'::xid)
-> Append
-> Result
-> Result
-(5 rows)
+(6 rows)
reset enable_hashagg;
--