Adding qualification conditions to EXPLAIN output - Mailing list pgsql-hackers

From Tom Lane
Subject Adding qualification conditions to EXPLAIN output
Date
Msg-id 19128.1015714937@sss.pgh.pa.us
Whole thread Raw
Responses Re: Adding qualification conditions to EXPLAIN output  (Bruce Momjian <pgman@candle.pha.pa.us>)
Re: Adding qualification conditions to EXPLAIN output  (Masaru Sugawara <rk73@sea.plala.or.jp>)
Re: Adding qualification conditions to EXPLAIN output  (Liam Stewart <liams@redhat.com>)
List pgsql-hackers
I have been fooling around with adding decompiled display of plan
qualification conditions to EXPLAIN output.  With this, you can
for example tell the difference between indexscanned and
not-indexscanned clauses, without having to dig through EXPLAIN
VERBOSE dumps.  Here is an example motivated by Rob Hoopman's
recent query on pgsql-general:

regression=# create table foo (f1 int, f2 int, f3 int, unique(f1,f2));
NOTICE:  CREATE TABLE / UNIQUE will create implicit index 'foo_f1_key' for table 'foo'
CREATE
regression=# explain select * from foo where f1 = 11;
INFO:  QUERY PLAN:

Index Scan using foo_f1_key on foo  (cost=0.00..17.07 rows=5 width=12) indxqual: (f1 = 11)

EXPLAIN
regression=# explain select * from foo where f1 = 11 and f2 = 44;
INFO:  QUERY PLAN:

Index Scan using foo_f1_key on foo  (cost=0.00..4.83 rows=1 width=12) indxqual: ((f1 = 11) AND (f2 = 44))

EXPLAIN
regression=# explain select * from foo where f1 = 11 and f3 = 44;
INFO:  QUERY PLAN:

Index Scan using foo_f1_key on foo  (cost=0.00..17.08 rows=1 width=12) indxqual: (f1 = 11) qual: (f3 = 44)

EXPLAIN
regression=# explain select * from foo where f2 = 11 and f3 = 44;
INFO:  QUERY PLAN:

Seq Scan on foo  (cost=0.00..25.00 rows=1 width=12) qual: ((f2 = 11) AND (f3 = 44))

EXPLAIN

The display of join conditions isn't yet ready for prime time:

regression=# explain select * from tenk1 a left join tenk1 b using (unique1)
regression-# where a.hundred < b.hundred;
INFO:  QUERY PLAN:

Merge Join  (cost=0.00..2343.45 rows=10000 width=296) merge: ("outer"."?column1?" = "inner"."?column16?") qual:
("outer"."?column7?"< "inner"."?column6?") ->  Index Scan using tenk1_unique1 on tenk1 a  (cost=0.00..1071.78
rows=10000width=148) ->  Index Scan using tenk1_unique1 on tenk1 b  (cost=0.00..1071.78 rows=10000 width=148)
 

EXPLAIN

but it's getting there.

Question for the group: does this seem valuable enough to put into the
standard EXPLAIN output, or should it be a special option?  I can
imagine showing it only in EXPLAIN VERBOSE's summary display, or adding
a GUC variable to enable it, or adding another option keyword to
EXPLAIN, but I don't much want to do any of those things.  On the other
hand, maybe this stuff won't make any sense to non-experts anyway.
Thoughts?
        regards, tom lane


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: [PATCHES] Small fix for _equalValue()
Next
From: Thomas Lockhart
Date:
Subject: Re: [PATCHES] Small fix for _equalValue()