pg_stat_statements and non default search_path

From: Julien Rouhaud <julien(dot)rouhaud(at)dalibo(dot)com>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: pg_stat_statements and non default search_path
Date: 2016-10-07 09:39:38
Message-ID: 8f54c609-17c6-945b-fe13-8b07c0866420@dalibo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello,

I've faced multiple times a painful limitation with pg_stat_statements.
Queries are normalized based on the textual SQL statements, and the
queryid is computed using objects' oids. So for instance with different
search_path settings, we can end up with the same normalized query but
different queryids, and there's no way to know what are the actual
relations each query is using. It also means that it can be almost
impossible to use the normalized query to replay a query.

I see two ways of fixing this. First one would be to store normalized
queries while fully qualifiying the relation's names. After a quick look
this can't be done without storing at least a token location in
RangeTblEntry nodes, which sounds like a bad idea.

The other way would be to store the value of search_path with each pgss
entry (either in shared_memory or in the external file).

Is it something that we should fix, and if yes is any of this
acceptable, or does someone see another way to solve this problem?

Regards.

--
Julien Rouhaud
http://dalibo.com - http://dalibo.org

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Banck 2016-10-07 10:34:14 pg_rewind: Should abort if both --source-pgdata and --source-server are specified
Previous Message Tomas Vondra 2016-10-07 09:32:53 Re: Speed up Clog Access by increasing CLOG buffers