pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Pallav Kalva <pkalva@deg.cc>
To: Scott Marlowe <smarlowe@g2switchworks.com>
Cc: pgsql-admin@postgresql.org
Subject: Re: SQL logging (log_min_duration_statement) not working
Date: Wed, 18 May 2005 14:06:46 -0400
Message-ID: <428B8436.8060007@deg.cc> (raw)
In-Reply-To: <1116431495.31821.22.camel@state.g2switchworks.com>
References: <428B4487.8010702@deg.cc>
	<1116427170.31821.10.camel@state.g2switchworks.com>
	<428B55FB.3030805@deg.cc>
	<1116431495.31821.22.camel@state.g2switchworks.com>

Scott Marlowe wrote:

>On Wed, 2005-05-18 at 09:49, Pallav Kalva wrote:
>  
>
>>Scott Marlowe wrote:
>>
>>    
>>
>>>On Wed, 2005-05-18 at 08:35, Pallav Kalva wrote:
>>> 
>>>
>>>      
>>>
>>>>Hi Everybody,
>>>>
>>>>
>>>>   I am having problems with logging long running SQL in the log file. 
>>>>I have set log_min_duration_statement = 5000 (5secs) and it is not 
>>>>logging sql statements that took over 5 secs and this is only from 
>>>>queries generated by Hibernate . here is a sample query from hibernate :
>>>>
>>>>-----------------------------------------------------------------------------------------
>>>>select listingadd1_.addressid as col_0_0_
>>>>        
>>>>
>>>>from listing.listing listing0_, listing.address listingadd1_
>>>      
>>>
>>>>where ((select count(taxrolls2_.fkaddressid)
>>>>      from listing.taxroll taxrolls2_
>>>>      where listingadd1_.addressid=taxrolls2_.fkaddressid)=0 )
>>>>      and(listing0_.fkbestaddressid=listingadd1_.addressid )
>>>>      and(listing0_.entrydate>$1 )
>>>>order by  listingadd1_.addressid asc
>>>>--------------------------------------------------------------------------------------------
>>>>
>>>> This above query take more than 5 secs to run and it wont get logged , 
>>>>where as all other queries which are not generated by Hibernate are 
>>>>logged. Is this expected behavior ?  am I missing something else ?  
>>>>Please advice.
>>>>   
>>>>
>>>>        
>>>>
>>>Are you sure it's taking more than 5 seconds to run, not that it's
>>>taking <5 seconds to run and >5 seconds to return the data.  I'm pretty
>>>sure the time it takes to ship out the data isn't counted in the time
>>>used to decide whether to log the query or not by the postmaster.
>>>
>>>I.e. what does explain analyze QUERY HERE say about the execution time?
>>>
>>> 
>>>
>>>      
>>>
>>Hi Scott,
>>
>>     Thanks! for the reply. The query for sure runs for more than 5 
>>secs, I  passed the same value again and ran the query in the psql with 
>>explain analyze .
>> 
>>    Here is the explain analyze output :
>>    
>>
>
>SNIP
>
>  
>
>>   ->  Nested Loop  (cost=0.00..17503496.52 rows=678 width=4) (actual 
>>time=5.185..31575.629 rows=398459 loops=1)
>>    
>>
>
>SNIP
>
>  
>
>> Total runtime: 38026.606 ms
>>(13 rows)
>>    
>>
>
>OK, two problems here, I assume.  One is your logging is dodgy right
>now.  Is postgresql logging anything else?  Are you sure your logs are
>going where you think they are, etc?
>

Postgres is logging everything else , even the queries which take more 
than 5 sec which are
executed from psql not the Hibernate queries. The main concern for me 
was to check if the bad
queries which are executed from Hibernate are logged or not.

>
>Secondly, it looks from the nested loop part of your explain analyze
>that there's a part where the query planner THINKS there's gonna be 678
>rows, but actually gets 398459, that's a miscalculation by a factor of
>about 600.  Since there's no functions or anything I recognize as being
>a common cause of such a mis-estimation, I'd guess that either you need
>to analyze, or if you have analyzed, you may need to alter the stats
>target for the column entrydate.
>
>---------------------------(end of broadcast)---------------------------
>TIP 6: Have you searched our list archives?
>
>               http://archives.postgresql.org
>
>  
>





view thread (10+ messages)  latest in thread

Message-ID: <428B8436.8060007@deg.cc>
Permalink:  ../428B8436.8060007@deg.cc/
Also on:    postgresql.org/message-id/428B8436.8060007@deg.cc

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-admin@postgresql.org
  Cc: pkalva@deg.cc, smarlowe@g2switchworks.com
  Subject: Re: SQL logging (log_min_duration_statement) not working
  In-Reply-To: <428B8436.8060007@deg.cc>
  References: <428B4487.8010702@deg.cc> <1116427170.31821.10.camel@state.g2switchworks.com> <428B55FB.3030805@deg.cc> <1116431495.31821.22.camel@state.g2switchworks.com> <428B8436.8060007@deg.cc>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox