Re: pg_stat_statements - Mailing list pgsql-general

From Simon Riggs
Subject Re: pg_stat_statements
Date
Msg-id CANbhV-GQTFnCZHbReR6S6wVxnqg3VEC6r5kDMtXhfU4wE5vWyg@mail.gmail.com
Whole thread Raw
In response to Re: pg_stat_statements  (Julien Rouhaud <rjuju123@gmail.com>)
Responses Re: pg_stat_statements  (Julien Rouhaud <rjuju123@gmail.com>)
List pgsql-general
On Wed, 12 Jan 2022 at 03:03, Julien Rouhaud <rjuju123@gmail.com> 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/



pgsql-general by date:

Previous
From: Julien Rouhaud
Date:
Subject: Re: pg_stat_statements
Next
From: Julien Rouhaud
Date:
Subject: Re: pg_stat_statements