Re: Confusing EXPLAIN output in case of inherited tables

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Ashutosh Bapat <ashutosh(dot)bapat(at)enterprisedb(dot)com>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Confusing EXPLAIN output in case of inherited tables
Date: 2012-09-21 17:12:09
Message-ID: 25855.1348247529@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I wrote:
> ... In the attached I've hacked around this by causing the planner to
> assign new aliases to RTEs that it replaces in this way (see planagg.c
> and prepunion.c diffs). This seems like a bit of a kluge, but it
> doesn't take much code. An alternative that I'm considering is to
> have EXPLAIN make a pre-pass over the plan tree to identify which
> RTEs will actually be referenced, and then consider only those RTEs
> while assigning aliases. This would be a great deal more code though,
> and code which would require maintenance every time we add plan node
> types etc. So I'm not sure it's really a better answer. Thoughts?

Attached is a second draft that does it like that. This adds about 130
lines to explain.c compared to the other way, but on reflection it's
probably a better solution compared to trying to kluge things in the
planner. The change in the select_views results shows that there's
at least one other case of duplicated RTE names that I'd not covered
with the two planner kluges.

I think the next question is whether we want to back-patch this.
Although the problem with incorrect view dumping is arguably a data
integrity issue (cf bug #7553), few enough people have hit it that
I'm not sure it's worth taking risks for. I'd feel better about
this code once it'd got through a beta test cycle. Comments?

regards, tom lane

Attachment Content-Type Size
fix-ruleutils-alias-selection-2.patch text/x-patch 57.4 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2012-09-21 17:59:36 Re: CREATE SCHEMA IF NOT EXISTS
Previous Message Tom Lane 2012-09-21 16:16:36 Re: 64-bit API for large object