On Wed, 12 Jan 2022 at 03:03, Julien Rouhaud <rjuju123@xxxxxxxxx> wrote: > > Hi, > > On Tue, Jan 11, 2022 at 03:04:14PM +0000, Dirschel, Steve wrote: > > > > I'm not sure if this is the correct distribution list for this type of > > question but I'll try anyways. We have an app that uses multiple schemas. > > It will do a set schema 'schema_name' and execute queries. The queries > > executed are the same regardless of the schema the connection set. > > > > In pg_stat_statements the exact same query will get a different queryid for > > each schema that executes the query. > > > > I'm unable to determine which queryid comes from which schema the query was > > executed under. Is anyone aware of a way to determine this? > > > > Unfortunately this is a known limitation. I see this as a beneficial feature. If the same SQL is executed against different sets of tables, each with different indexes, probably different data, the performance could vary dramatically and might need different tuning on each. So having separate rows in the pg_stat_statements output makes sense. > There were some previous discussions (e.g. [1] and [2] more recently), but I > don't think there was a real consensus on how to solve that problem. To differentiate, run each schema using a different user, so you can tell them apart. -- Simon Riggs http://www.EnterpriseDB.com/