Re: pg_stat_statement normalization fails due to temporary tables

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andres Freund <andres(at)2ndquadrant(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: pg_stat_statement normalization fails due to temporary tables
Date: 2014-12-02 14:59:00
Message-ID: 639.1417532340@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Andres Freund <andres(at)2ndquadrant(dot)com> writes:
> pg_stat_statement's query normalization fails when temporary tables are
> used in a query. That's because JumbleRangeTable() uses the relid in the
> RTE to build the query fingerprint. I think in this case pgss from 9.1
> actually would do better than 9.2+ as the hash lookup previously didn't
> use the relid.

> I don't really have a good idea about fixing this though. The best thing
> that comes to mind is simply use eref->aliasname for the
> disambiguation...

Hmm ... by "fails" I suppose you mean "doesn't treat two different
instances of the same temp table name as the same"? I'm not sure
that's a bug.

If we go over to using the aliasname then "select x from foo a" and
"select x from bar a" would be treated as the same query, which
clearly *is* a bug. More generally, I don't think that schema1.tab
and schema2.tab should be considered the same table for this purpose.
So it's hard to see how to do much better than using the OID.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2014-12-02 15:04:52 Re: pg_stat_statement normalization fails due to temporary tables
Previous Message Robert Haas 2014-12-02 14:55:55 Re: [v9.5] Custom Plan API