Re: magical eref alias names

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Peter Eisentraut <peter(at)eisentraut(dot)org>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: magical eref alias names
Date: 2025-01-02 20:27:01
Message-ID: 300130.1735849621@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Robert Haas <robertmhaas(at)gmail(dot)com> writes:
> On Sun, Dec 22, 2024 at 12:45 PM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>> In particular, in a situation where we're trying to show a plan for
>> a query with inlined views, EXPLAIN would probably have to have code
>> to unique-ify the names anyway --- there's no way we're going to make
>> these nonce names globally unique, so the view(s) might contain names
>> that conflict with each other or the outer query.

> When you say "there's no way we're going to make these nonce names
> globally unique," is that because you think it would be too costly
> from a performance perspective (which was my concern) or that you
> think it's flat-out impossible for some reason (which doesn't seem to
> me to be true)?

Global uniqueness across the database (not single queries) would be
needed to prevent cases where different views use the same generated
names. The only way I can see to do that without nasty performance
costs is to use something like an OID counter. Which would mean
that rather than nice names like "union_1", "union_2", etc, you'd
soon be looking at "union_5846926". I don't think anyone would
find that to be an improvement on what we're doing now.

> If we had global uniqueness, or even per-subquery-level uniqueness,
> this would sort itself out somewhat nicely, I think. We would just end
> up with select_1 and select_2 or union_1 and union_2 or something like
> that, and I think that would be strictly better than the status quo
> where we do sometimes generate *SELECT* %d, but also sometimes just
> *SELECT* and other times unnamed_subquery, and also only ever *VALUES*
> and not *VALUES* %d.

I'll concede that it'd be nicer. But I'm not convinced it'd be enough
nicer to justify the costs of changing. We've been doing it this way
for a long time, and AFAIR you're the first to complain about it.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2025-01-02 20:43:12 Re: apply_scanjoin_target_to_paths and partitionwise join
Previous Message Larry Rosenman 2025-01-02 20:26:28 Fwd: Re: A new look at old NFS readdir() problems?