display of variables in EXPLAIN VERBOSE

Поиск
Список
Период
Сортировка
От Amit Langote
Тема display of variables in EXPLAIN VERBOSE
Дата
Msg-id b04a8d5d-2c79-f857-2e8d-3790e77dffe5@lab.ntt.co.jp
обсуждение исходный текст
Ответы Re: display of variables in EXPLAIN VERBOSE  (David Rowley <david.rowley@2ndquadrant.com>)
Список pgsql-hackers
Hi,

ISTM show_plan_tlist()'s rule of whether to the show range table prefix
with displayed variables contradicts the description of the VERBOSE option
in EXPLAIN documentation, which is as follows:

=======
VERBOSE

Display additional information regarding the plan. Specifically, include
the output column list for each node in the plan tree, schema-qualify
table and function names, always label variables in expressions with their
range table alias, and always print the name of each trigger for which
statistics are displayed. This parameter defaults to FALSE.
=======

Specifically, the current behavior contradicts the part of the sentence
that says "always label variables in expressions with their range table
alias".  See this example:

create table foo (a int);
create table foo1 () inherits (foo);

-- "a" is not labeled here
explain verbose select * from only foo order by 1;
                           QUERY PLAN
────────────────────────────────────────────────────────────────
 Sort  (cost=0.01..0.02 rows=1 width=4)
   Output: a
   Sort Key: foo.a
   ->  Seq Scan on public.foo  (cost=0.00..0.00 rows=1 width=4)
         Output: a
(5 rows)

-- it's labeled in this case
explain verbose select * from foo order by 1;
                                QUERY PLAN
───────────────────────────────────────────────────────────────────────────
 Sort  (cost=192.60..198.98 rows=2551 width=4)
   Output: foo.a
   Sort Key: foo.a
   ->  Append  (cost=0.00..48.26 rows=2551 width=4)
         ->  Seq Scan on public.foo  (cost=0.00..0.00 rows=1 width=4)
               Output: foo.a
         ->  Seq Scan on public.foo1  (cost=0.00..35.50 rows=2550 width=4)
               Output: foo1.a
(8 rows)

Seeing that "Sort Key" is always displayed with the range table alias, I
checked explain.c to see why the discrepancy exists and it seems that
show_plan_tlist() (and show_tablesample()) use the following condition for
whether or not to use the range table prefix:

    useprefix = list_length(es->rtable) > 1;

whereas other functions, including show_sort_group_keys() that prints the
"Sort Key", use the following condition:

    useprefix = (list_length(es->rtable) > 1 || es->verbose);

I can think of two ways we could do:

1. Change show_plan_tlist() and show_tablesample() to use the same rule as
others

2. Change other functions to use the same rule as show_plan_tlist(), also
updating the documentation to note the exceptional case when column names
are not prefixed

Thoughts?

Thanks,
Amit




В списке pgsql-hackers по дате отправления:

Предыдущее
От: Kyotaro HORIGUCHI
Дата:
Сообщение: Re: standby recovery fails (tablespace related) (tentative patchand discussion)
Следующее
От: Pavel Stehule
Дата:
Сообщение: Re: Allow any[] as input arguments for sql/plpgsql functions to mimic format()