Re: Adding locks statistics

2025-08-12 Thread Bertrand Drouvot
Hi, On Tue, Aug 12, 2025 at 08:42:48AM -0700, Jeff Davis wrote: > On Tue, 2025-08-12 at 09:37 +, Bertrand Drouvot wrote: > > It can be used for example for: > > > > 1. checking if "waits" is close to "requests". Then it means you > > usually have to > > wait before acquiring the lock, which m

Re: Adding locks statistics

2025-08-12 Thread Bertrand Drouvot
Hi, On Tue, Aug 12, 2025 at 08:54:07AM -0400, Greg Sabino Mullane wrote: > On Tue, Aug 12, 2025 at 5:32 AM Bertrand Drouvot < > bertranddrouvot...@gmail.com> wrote: > > > Docs: seem good. Needs a section on how to reset via > > > SELECT pg_stat_reset_shared('lock'); > > > > I meant something clo

Re: Adding locks statistics

2025-08-12 Thread Jeff Davis
On Tue, 2025-08-12 at 09:37 +, Bertrand Drouvot wrote: > It can be used for example for: > > 1. checking if "waits" is close to "requests". Then it means you > usually have to > wait before acquiring the lock, which means you may have a > concurrency issue. > > 2. lock_timeout and deadlock_ti

Re: Adding locks statistics

2025-08-12 Thread Greg Sabino Mullane
On Tue, Aug 12, 2025 at 5:32 AM Bertrand Drouvot < bertranddrouvot...@gmail.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

Re: Adding locks statistics

2025-08-12 Thread Bertrand Drouvot
Hi, On Mon, Aug 11, 2025 at 07:49:45PM -0400, Tom Lane wrote: > Michael Paquier writes: > > On Mon, Aug 11, 2025 at 02:53:58PM -0700, Jeff Davis wrote: > >> Can you describe your use case? I'd like to understand whether this is > >> useful for users, hackers, or both. > > > This is a DBA feature

Re: Adding locks statistics

2025-08-12 Thread Bertrand Drouvot
Hi, On Tue, Aug 12, 2025 at 08:44:58AM +0900, Michael Paquier wrote: > On Mon, Aug 11, 2025 at 02:53:58PM -0700, Jeff Davis wrote: > > On Mon, 2025-08-11 at 13:54 -0400, Greg Sabino Mullane wrote: > > > Great idea. +1. Here is a quick overall review to get things started. > > > > Can you describe

Re: Adding locks statistics

2025-08-12 Thread Bertrand Drouvot
Hi, On Mon, Aug 11, 2025 at 01:54:38PM -0400, Greg Sabino Mullane wrote: > Great idea. +1. Here is a quick overall review to get things started. Thanks for looking at it! > Meta: > patch did not apply via "git apply". Also has carriage returns (e.g. DOS > file), and some errant whitespace. Inte

Re: Adding locks statistics

2025-08-11 Thread Tom Lane
Michael Paquier writes: > On Mon, Aug 11, 2025 at 02:53:58PM -0700, Jeff Davis wrote: >> Can you describe your use case? I'd like to understand whether this is >> useful for users, hackers, or both. > This is a DBA feature, so the questions I'd ask myself are basically: > - Is there any decision-

Re: Adding locks statistics

2025-08-11 Thread Michael Paquier
On Mon, Aug 11, 2025 at 02:53:58PM -0700, Jeff Davis wrote: > On Mon, 2025-08-11 at 13:54 -0400, Greg Sabino Mullane wrote: > > Great idea. +1. Here is a quick overall review to get things started. > > Can you describe your use case? I'd like to understand whether this is > useful for users, hacke

Re: Adding locks statistics

2025-08-11 Thread Jeff Davis
On Mon, 2025-08-11 at 13:54 -0400, Greg Sabino Mullane wrote: > Great idea. +1. Here is a quick overall review to get things started. Can you describe your use case? I'd like to understand whether this is useful for users, hackers, or both. Regards, Jeff Davis

Re: Adding locks statistics

2025-08-11 Thread Greg Sabino Mullane
Great idea. +1. Here is a quick overall review to get things started. Meta: patch did not apply via "git apply". Also has carriage returns (e.g. DOS file), and some errant whitespace. Seems to pass pgindent, though. Name: I think the name would read better as pg_stat_locks, especially as it retur

Adding locks statistics

2025-08-01 Thread Bertrand Drouvot
Hi hackers, Please find attached a patch to add a new view (namely pg_stat_lock) that provides lock statistics. It’s output is like the following: postgres=# select * from pg_stat_lock; locktype | requests | waits | timeouts | deadlock_timeouts | deadlocks | fastpath | stat