Re: how to trace a backend session

From: Dominique Devienne <ddevienne(at)gmail(dot)com>
To: Pierre Forstmann <pierre(dot)forstmann(at)gmail(dot)com>
Cc: James Pang <jamespang886(at)gmail(dot)com>, pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: how to trace a backend session
Date: 2024-01-24 08:16:57
Message-ID: CAFCRh-85NEkkKH3Db74n_FxE9OO8itQX0dz0Xz=-d0bTsfHh4Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

>
> Le lun. 22 janv. 2024 à 08:29, James Pang <jamespang886(at)gmail(dot)com> a
> écrit :
>
>> [...] we used to turn on Oracle session trace(that will capture all
>> activities,
>>
> SQL statements, waiting, waiting time), to do living troubleshooting.
>>
> could you direct any similar tracing in Postgresql v13 , v14.
>>
>
On Tue, Jan 23, 2024 at 7:45 PM Pierre Forstmann <pierre(dot)forstmann(at)gmail(dot)com>
wrote:

> I have coded an extension to trace SQL statements for specific backends:
> https://github.com/pierreforstmann/pg_log_statements
> (only SQL statements are traced - no wait events data is collected).
>

There's also the possibility of activating client-side tracing with libpq,
if you are using it:
https://www.postgresql.org/docs/current/libpq-control.html#LIBPQ-PQTRACE

Not the same thing as server-side tracing, of course. But can be useful.
--DD

PS: Although that trace is not easily machine parse'able, it is at least
human readable (kinda...)
(see https://www.spinics.net/lists/pgsql/msg218580.html)

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Mickaël SALMON 2024-01-24 10:48:30 about statement execution times in the logs
Previous Message Sasmit Utkarsh 2024-01-24 04:44:52 Re: Need assistance for running postgresql procedures