pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Laurenz Albe <laurenz.albe@cybertec.at>
To: Rajesh Kumar <rajeshkumar.dba09@gmail.com>
To: Pgsql-admin <pgsql-admin@lists.postgresql.org>
Subject: Re: Connection hike
Date: Wed, 13 Mar 2024 13:56:08 +0100
Message-ID: <c23283b7aaa8deb64dc1afddfe509ca79e1dfe5e.camel@cybertec.at> (raw)
In-Reply-To: <CAJk5AtY-dKfsCEk=mg=qkhtpT1NbeGsYN9wLiKZ9JTem_9w3ig@mail.gmail.com>
References: <CAJk5AtY-dKfsCEk=mg=qkhtpT1NbeGsYN9wLiKZ9JTem_9w3ig@mail.gmail.com>

On Wed, 2024-03-13 at 18:14 +0530, Rajesh Kumar wrote:
> There were connections hike and I used to check blocking sessions and long
> running queries using pg_stat_activity.
> 
> My manager gave me less rating during performance meeting, because he says
> even a kid can do this. He said my job is to analyse the cause of connection hike. 
> 
> Any idea how to analyse?

I assume that you mean "hang", not "hike".

You can diagnose locked sessions fron the "wait_event" and "wait_event_type" in
"pg_stat_activity".  For the process ID of a blocked session, you can call the
"pg_blocking_pids()" function to get the process IDs of the sessions blocking it.

You can look at "pg_locks" to see on which object the lock is (a lock waiting
for a transaction is waiting for a row lock).

That's about all you can analyze in the database.  To figure out which statements
took the locks that block others, you'd have to debug the application.

Yours,
Laurenz Albe





view thread (4+ messages)  latest in thread

Message-ID: <c23283b7aaa8deb64dc1afddfe509ca79e1dfe5e.camel@cybertec.at>
Permalink:  ../c23283b7aaa8deb64dc1afddfe509ca79e1dfe5e.camel@cybertec.at/
Also on:    postgresql.org/message-id/c23283b7aaa8deb64dc1afddfe509ca79e1dfe5e.camel@cybertec.at

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-admin@postgresql.org
  Cc: laurenz.albe@cybertec.at, rajeshkumar.dba09@gmail.com, pgsql-admin@lists.postgresql.org
  Subject: Re: Connection hike
  In-Reply-To: <c23283b7aaa8deb64dc1afddfe509ca79e1dfe5e.camel@cybertec.at>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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