On Mon, 22 Apr 2019 at 19:49, Amit Langote <langote_amit...@lab.ntt.co.jp> wrote: > 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
I'd vote to make the code match the documentation, but probably implement it by adding a new field to ExplainState and just calculate what to do once in ExplainQuery() instead of calculating what to do in various random places. I don't think we should backpatch this change, likely it would be better to keep the explain output as stable as possible in the back branches, so that might mean a documentation tweak should be done for them. -- David Rowley http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services