Re: pg_stat_statement normalization fails due to temporary tables - Mailing list pgsql-hackers

From Tom Lane
Subject Re: pg_stat_statement normalization fails due to temporary tables
Date
Msg-id 639.1417532340@sss.pgh.pa.us
Whole thread Raw
In response to pg_stat_statement normalization fails due to temporary tables  (Andres Freund <andres@2ndquadrant.com>)
Responses Re: pg_stat_statement normalization fails due to temporary tables  (Andres Freund <andres@2ndquadrant.com>)
List pgsql-hackers
Andres Freund <andres@2ndquadrant.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



pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: [v9.5] Custom Plan API
Next
From: Andres Freund
Date:
Subject: Re: pg_stat_statement normalization fails due to temporary tables