Re: Adding locks statistics

From: Greg Sabino Mullane <htamfids(at)gmail(dot)com>
To: Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Adding locks statistics
Date: 2025-08-12 12:54:07
Message-ID: CAKAnmmJ+WW8=28dvQGvPvGh1APh0FxDbdTkdahoatN35y2cgxw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Aug 12, 2025 at 5:32 AM Bertrand Drouvot <
bertranddrouvot(dot)pg(at)gmail(dot)com> wrote:

> I considered pg_stat_locks, but chose the singular form to be consistent
> with
> pg_stat_database, pg_stat_subscription, and friends.
>

Counter-examples: pg_stat_statements, pg_stat_subscription_stats. Our names
are not consistent. :) It just feels a better fit to have a plural name for
a table tracking aggregates of multiple types of objects.

(Ignore my git complaint, was obviously half-asleep when I wrote that).

> Docs: seem good. Needs a section on how to reset via
> > SELECT pg_stat_reset_shared('lock');
>

I meant something closer to the actual description of the view. Having it
buried in the pg_stat_reset_shared section is not intuitive for people
looking up the view in the docs.

> Because it looks like that they are ordered by alphabetical order.
>

That makes sense.

> - I'm not sure that's worth for this particular case and code paths.
>

Will let others opine on that.

Thanks! Did you observe some noticeable performance penalties?
>

No, but I did not give it any particularly heavy testing. More of a idle
thought when pulling up a brand new system and seeing the thousands of
locks for the tiniest bit of database action.

Cheers,
Greg

--
Crunchy Data - https://www.crunchydata.com
Enterprise Postgres Software Products & Tech Support

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Fujii Masao 2025-08-12 13:02:32 Re: Excessive LOG messages from replication slot sync worker
Previous Message Mikhail Kharitonov 2025-08-12 12:02:33 Re: [PATCH] Fix replica identity mismatch for partitioned tables with publish_via_partition_root