Re: proposal: enhancing slow query log, and autoexplain log about waiting on lock before query exec time

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Jim Nasby <Jim(dot)Nasby(at)bluetreble(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: proposal: enhancing slow query log, and autoexplain log about waiting on lock before query exec time
Date: 2016-02-21 15:39:46
Message-ID: CAFj8pRCA91OoG2M1VHn=9rJtQKTU44bSkjq15Ve-L6_Ej2y6Ag@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi

>> What would be useful logging-wise is if the log line for the query itself
>> could contain lock wait time, but that doesn't sound like what you're
>> proposing?
>>
>
> I hope, so I propose this idea. First time I wanted talk about the idea.
> Next step is the talk about format.
>

Some enhancement should to have two parts:

a) introduce new function GetCurrentStatementStartExecutionTimestamp().
This function can be used for calculation of initial lock waiting duration.

b) introduce new GUC log_min_lock_duration_statement. It is similar to
log_min_duration_statement. When any statement waits longer time than this
number, then statement is logged similar to other slow statement.

example:

log_min_duration_statement = 1000 .. log any slower than 1sec
log_min_lock_duration_statement = 100 log when waiting is longer than 100 ms

entry in log:

LOG: duration:843 ms start lock duration: 156 ms statement: .....

This logic is simple - for some more complicated models, we can introduce
some monitoring logs hooks and complex custom logging can be solved in
extension.

When log_min_lock_duration_statement is -1, then "start lock duration"
isn't printed to log.

Comments, notes?

Regards

Pavel

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2016-02-21 16:38:29 pgsql: Cosmetic improvements in new config_info code.
Previous Message Andrew Dunstan 2016-02-21 14:37:39 Re: [Pgbuildfarm-members] Release 4.17 of the PostgreSQL Buildfarm client