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