pg.ddx.io pgsql-general@postgresql.org mailing list archive
help / color / mirror / Atom feedpg_stat_statements
6+ messages / 3 participants
[nested] [flat]
* pg_stat_statements
@ 2022-01-11 15:04 Dirschel, Steve <steve.dirschel@thomsonreuters.com>
2022-01-12 03:03 ` Re: pg_stat_statements Julien Rouhaud <rjuju123@gmail.com>
0 siblings, 1 reply; 6+ messages in thread
From: Dirschel, Steve @ 2022-01-11 15:04 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
Hello,
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?
Thanks in advance.
Steve
This e-mail is for the sole use of the intended recipient and contains information that may be privileged and/or confidential. If you are not an intended recipient, please notify the sender by return e-mail and delete this e-mail and any attachments. Certain required legal entity disclosures can be accessed on our website: https://www.thomsonreuters.com/en/resources/disclosures.html
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: pg_stat_statements
2022-01-11 15:04 pg_stat_statements Dirschel, Steve <steve.dirschel@thomsonreuters.com>
@ 2022-01-12 03:03 ` Julien Rouhaud <rjuju123@gmail.com>
2022-01-12 10:22 ` Re: pg_stat_statements Simon Riggs <simon.riggs@enterprisedb.com>
0 siblings, 1 reply; 6+ messages in thread
From: Julien Rouhaud @ 2022-01-12 03:03 UTC (permalink / raw)
To: Dirschel, Steve <steve.dirschel@thomsonreuters.com>; +Cc: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
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.
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.
Storing a query text with fully qualified names (either the current query or a
new field) is not practical for performance purpose, but there were no
objections to storing additional information, like the active search_path when
the entry was created. But as noted, while it technically gives the
information you need it's far from being convenient to use, which is probably
why it was never implemented.
[1] https://www.postgresql.org/message-id/flat/8f54c609-17c6-945b-fe13-8b07c0866420%40dalibo.com
[2] https://www.postgresql.org/message-id/flat/9baf5c06-d6ab-c688-010c-843348e3d98c%40gmail.com
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: pg_stat_statements
2022-01-11 15:04 pg_stat_statements Dirschel, Steve <steve.dirschel@thomsonreuters.com>
2022-01-12 03:03 ` Re: pg_stat_statements Julien Rouhaud <rjuju123@gmail.com>
@ 2022-01-12 10:22 ` Simon Riggs <simon.riggs@enterprisedb.com>
2022-01-12 10:31 ` Re: pg_stat_statements Julien Rouhaud <rjuju123@gmail.com>
0 siblings, 1 reply; 6+ messages in thread
From: Simon Riggs @ 2022-01-12 10:22 UTC (permalink / raw)
To: Julien Rouhaud <rjuju123@gmail.com>; +Cc: Dirschel, Steve <steve.dirschel@thomsonreuters.com>; pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
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/
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: pg_stat_statements
2022-01-11 15:04 pg_stat_statements Dirschel, Steve <steve.dirschel@thomsonreuters.com>
2022-01-12 03:03 ` Re: pg_stat_statements Julien Rouhaud <rjuju123@gmail.com>
2022-01-12 10:22 ` Re: pg_stat_statements Simon Riggs <simon.riggs@enterprisedb.com>
@ 2022-01-12 10:31 ` Julien Rouhaud <rjuju123@gmail.com>
2022-01-12 13:17 ` Re: pg_stat_statements Simon Riggs <simon.riggs@enterprisedb.com>
0 siblings, 1 reply; 6+ messages in thread
From: Julien Rouhaud @ 2022-01-12 10:31 UTC (permalink / raw)
To: Simon Riggs <simon.riggs@enterprisedb.com>; +Cc: Dirschel, Steve <steve.dirschel@thomsonreuters.com>; pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
On Wed, Jan 12, 2022 at 10:22:38AM +0000, Simon Riggs wrote:
> On Wed, 12 Jan 2022 at 03:03, Julien Rouhaud <rjuju123@gmail.com> wrote:
> >
> > 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.
Yes, having different rows seems like a good thing. But being unable to tell
which row apply to which schema is *not* a good thing.
> > 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.
This isn't always possible. For instance, once you reach enough schema it will
be problematic to do proper pooling.
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: pg_stat_statements
2022-01-11 15:04 pg_stat_statements Dirschel, Steve <steve.dirschel@thomsonreuters.com>
2022-01-12 03:03 ` Re: pg_stat_statements Julien Rouhaud <rjuju123@gmail.com>
2022-01-12 10:22 ` Re: pg_stat_statements Simon Riggs <simon.riggs@enterprisedb.com>
2022-01-12 10:31 ` Re: pg_stat_statements Julien Rouhaud <rjuju123@gmail.com>
@ 2022-01-12 13:17 ` Simon Riggs <simon.riggs@enterprisedb.com>
2022-01-12 14:43 ` Re: pg_stat_statements Simon Riggs <simon.riggs@enterprisedb.com>
0 siblings, 1 reply; 6+ messages in thread
From: Simon Riggs @ 2022-01-12 13:17 UTC (permalink / raw)
To: Julien Rouhaud <rjuju123@gmail.com>; +Cc: Dirschel, Steve <steve.dirschel@thomsonreuters.com>; pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
On Wed, 12 Jan 2022 at 10:31, Julien Rouhaud <rjuju123@gmail.com> wrote:
>
> On Wed, Jan 12, 2022 at 10:22:38AM +0000, Simon Riggs wrote:
> > On Wed, 12 Jan 2022 at 03:03, Julien Rouhaud <rjuju123@gmail.com> wrote:
> > >
> > > 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.
>
> Yes, having different rows seems like a good thing. But being unable to tell
> which row apply to which schema is *not* a good thing.
>
> > > 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.
>
> This isn't always possible. For instance, once you reach enough schema it will
> be problematic to do proper pooling.
True, perhaps we should fix SET SESSION AUTHORIZATION to be allowed by
non-superusers. Then set the user and search_path at same time.
I was going to suggest adding a comment to the front of each SQL that
contains the schema, but that doesn't work either (and looks like a
bug, but how normalization works is not documented).
--
Simon Riggs http://www.EnterpriseDB.com/
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: pg_stat_statements
2022-01-11 15:04 pg_stat_statements Dirschel, Steve <steve.dirschel@thomsonreuters.com>
2022-01-12 03:03 ` Re: pg_stat_statements Julien Rouhaud <rjuju123@gmail.com>
2022-01-12 10:22 ` Re: pg_stat_statements Simon Riggs <simon.riggs@enterprisedb.com>
2022-01-12 10:31 ` Re: pg_stat_statements Julien Rouhaud <rjuju123@gmail.com>
2022-01-12 13:17 ` Re: pg_stat_statements Simon Riggs <simon.riggs@enterprisedb.com>
@ 2022-01-12 14:43 ` Simon Riggs <simon.riggs@enterprisedb.com>
0 siblings, 0 replies; 6+ messages in thread
From: Simon Riggs @ 2022-01-12 14:43 UTC (permalink / raw)
To: Julien Rouhaud <rjuju123@gmail.com>; +Cc: Dirschel, Steve <steve.dirschel@thomsonreuters.com>; pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
On Wed, 12 Jan 2022 at 13:17, Simon Riggs <simon.riggs@enterprisedb.com> wrote:
>
> On Wed, 12 Jan 2022 at 10:31, Julien Rouhaud <rjuju123@gmail.com> wrote:
> >
> > On Wed, Jan 12, 2022 at 10:22:38AM +0000, Simon Riggs wrote:
> > > On Wed, 12 Jan 2022 at 03:03, Julien Rouhaud <rjuju123@gmail.com> wrote:
> > > >
> > > > 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.
> >
> > Yes, having different rows seems like a good thing. But being unable to tell
> > which row apply to which schema is *not* a good thing.
> >
> > > > 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.
> >
> > This isn't always possible. For instance, once you reach enough schema it will
> > be problematic to do proper pooling.
>
> True, perhaps we should fix SET SESSION AUTHORIZATION to be allowed by
> non-superusers. Then set the user and search_path at same time.
But SET ROLE works.
--
Simon Riggs http://www.EnterpriseDB.com/
^ permalink raw reply [nested|flat] 6+ messages in thread
end of thread, other threads:[~2022-01-12 14:43 UTC | newest]
Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2022-01-11 15:04 pg_stat_statements Dirschel, Steve <steve.dirschel@thomsonreuters.com>
2022-01-12 03:03 ` Julien Rouhaud <rjuju123@gmail.com>
2022-01-12 10:22 ` Simon Riggs <simon.riggs@enterprisedb.com>
2022-01-12 10:31 ` Julien Rouhaud <rjuju123@gmail.com>
2022-01-12 13:17 ` Simon Riggs <simon.riggs@enterprisedb.com>
2022-01-12 14:43 ` Simon Riggs <simon.riggs@enterprisedb.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox