log_min_duration_statement feature

Started by Christopher Kings-Lynneover 23 years ago4 messagespatches
Jump to latest
#1Christopher Kings-Lynne
chriskl@familyhealth.com.au

OK,

I've implemented the TODO feature:

* Add GUC log_statement_and_duration to print statement and >= min
duration

..except I've given it a more consistent name.

This new feature will really help me find slow queries in my codebase.

The only thing that I'm not 100% on is the ong >= int * 1000 comparison I
do - will that overflow if the user has supplied max int?

Chris

Attachments:

guc.txttext/plain; name=guc.txtDownload+70-36
#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Christopher Kings-Lynne (#1)
Re: log_min_duration_statement feature

Christopher Kings-Lynne <chriskl@familyhealth.com.au> writes:

The only thing that I'm not 100% on is the ong >= int * 1000 comparison I
do - will that overflow if the user has supplied max int?

Yes. Consider declaring the "max value" in the GUC variable's info block
as INT_MAX/1000 instead of INT_MAX.

(We should go through all of the GUC variables with an eye to places
where the max value is unrealistically high, but for the moment I'll
settle for not introducing any new sillinesses ...)

regards, tom lane

#3Christopher Kings-Lynne
chriskl@familyhealth.com.au
In reply to: Christopher Kings-Lynne (#1)
Re: log_min_duration_statement feature

Yes. Consider declaring the "max value" in the GUC variable's info block
as INT_MAX/1000 instead of INT_MAX.

(We should go through all of the GUC variables with an eye to places
where the max value is unrealistically high, but for the moment I'll
settle for not introducing any new sillinesses ...)

OK, actually would it make more sense to just make it so that the duration
threshold is given in microseconds instead of milliseconds? Then I wouldn't
have to multiply and people can threshold lower as well...?

Chris

#4Bruce Momjian
bruce@momjian.us
In reply to: Christopher Kings-Lynne (#3)
Re: log_min_duration_statement feature

Christopher Kings-Lynne wrote:

Yes. Consider declaring the "max value" in the GUC variable's info block
as INT_MAX/1000 instead of INT_MAX.

(We should go through all of the GUC variables with an eye to places
where the max value is unrealistically high, but for the moment I'll
settle for not introducing any new sillinesses ...)

OK, actually would it make more sense to just make it so that the duration
threshold is given in microseconds instead of milliseconds? Then I wouldn't
have to multiply and people can threshold lower as well...?

As I remember all our other timings are in milliseconds so unless there
is a good reason, we should be consistent.

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073