Thread: log_min_duration_statement feature
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
Attachment
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
> 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
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