Thread: Fetch statements

Fetch statements

From
Carlos Benkendorf
Date:
Hi,
 
I´m trying to discover some bad SQL statements in our environment but the logs are not helping too much... they say we´ve some very bad fetch statements but I don´t know how to discover the corresponding SELECT statement...  How can I find them?
 
Some example:
<10.0.1.122(3821) 5072 2005-12-16 10:36:12 BRST FETCH>LOG:  duration: 1855.818 ms  statement: fetch 1 in cur65c
thanks in advance!
 
Benkendorf


Yahoo! doce lar. Faça do Yahoo! sua homepage.

Re: Fetch statements

From
Michael Fuhr
Date:
On Fri, Dec 16, 2005 at 06:28:03PM +0000, Carlos Benkendorf wrote:
> I´m trying to discover some bad SQL statements in our environment
> but the logs are not helping too much... they say we´ve some very
> bad fetch statements but I don´t know how to discover the
> corresponding SELECT statement...  How can I find them?

What do you mean by "bad"?  Are the statements causing errors, or
are they just taking longer to run than you think they should?  The
following log entry suggests the latter.

> Some example:
> <10.0.1.122(3821) 5072 2005-12-16 10:36:12 BRST FETCH>LOG:  duration: 1855.818 ms  statement: fetch 1 in cur65c

Do your logs contain the DECLARE statement for the cur65c cursor?
If not, are you logging all statements or only those that last
longer than a certain amount of time (log_min_duration_statement)?

--
Michael Fuhr

Re: Fetch statements

From
Carlos Benkendorf
Date:
Sorry,
 
I would like to say "take longer than" with "bad" statements... but I´m only logging statements that take longer than 700 ms and DECLARE statements are not logged of course.
 
I think the only way in my case is logging all statements... Am I right? Or is there another way?
 
Thanks!
 
Michael Fuhr <mike@fuhr.org> escreveu:
On Fri, Dec 16, 2005 at 06:28:03PM +0000, Carlos Benkendorf wrote:
> I´m trying to discover some bad SQL statements in our environment
> but the logs are not helping too much... they say we´ve some very
> bad fetch statements but I don´t know how to discover the
> corresponding SELECT statement... How can I find them?

What do you mean by "bad"? Are the statements causing errors, or
are they just taking longer to run than you think they should? The
following log entry suggests the latter.

> Some example:
> <10.0.1.122(3821) 5072 2005-12-16 10:36:12 BRST FETCH>LOG: duration: 1855.818 ms statement: fetch 1 in cur65c

Do your logs contain the DECLARE statement for the cur65c cursor?
If not, are you logging all statements or only those that last
longer than a certain amount of time (log_min_duration_statement)?

--
Michael Fuhr


Yahoo! doce lar. Faça do Yahoo! sua homepage.

Re: Fetch statements

From
Michael Fuhr
Date:
On Fri, Dec 16, 2005 at 08:49:32PM +0000, Carlos Benkendorf wrote:
> I would like to say "take longer than" with "bad" statements...
> but I´m only logging statements that take longer than 700 ms
> and DECLARE statements are not logged of course.
>
> I think the only way in my case is logging all statements... Am I
> right? Or is there another way?

Check the logging documentation to be sure, but I think you'll have
to log all statements.

--
Michael Fuhr