Received: from localhost (maia-2.hub.org [200.46.204.187]) by postgresql.org (Postfix) with ESMTP id 2B7089FBBB4 for ; Tue, 24 Jul 2007 23:55:51 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.187]) (amavisd-maia, port 10024) with ESMTP id 40188-04 for ; Tue, 24 Jul 2007 23:55:41 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from FS.denninger.net (wsip-70-169-168-7.pn.at.cox.net [70.169.168.7]) by postgresql.org (Postfix) with ESMTP id 4FA6B9FBBB3 for ; Tue, 24 Jul 2007 23:55:47 -0300 (ADT) Received: from [192.168.1.13] (localhost [127.0.0.1]) by FS.denninger.net (8.13.8/8.13.1) with SMTP id l6P2tjt4040736 for ; Tue, 24 Jul 2007 21:55:45 -0500 (CDT) (envelope-from karl@denninger.net) Received: from [192.168.1.13] [192.168.1.13] by Spamblock-sys (LOCAL); Tue Jul 24 21:55:45 2007 Message-ID: <46A6BBB1.1020502@denninger.net> Date: Tue, 24 Jul 2007 21:55:45 -0500 From: Karl Denninger User-Agent: Thunderbird 2.0.0.5 (Windows/20070716) MIME-Version: 1.0 To: Tom Lane CC: pgsql-performance@postgresql.org Subject: Re: Performance issue with 8.2.3 - "C" application References: <46A6A549.1040606@denninger.net> <29633.1185331558@sss.pgh.pa.us> In-Reply-To: <29633.1185331558@sss.pgh.pa.us> Content-Type: multipart/alternative; boundary="------------090003060500060403020307" X-SPAMBLOCK-MATCH: Matched [@postgresql.org+], message ok X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.132 tagged_above=0 required=5 tests=AWL=0.216, BAYES_40=-0.185, HTML_MESSAGE=0.001, RDNS_DYNAMIC=0.1 X-Spam-Level: X-Archive-Number: 200707/328 X-Sequence-Number: 26012 This is a multi-part message in MIME format. --------------090003060500060403020307 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Yeah, the problem doesn't appear to be there. As I said, if I look at the PS of the system when its bogging, there aren't a whole bunch of processes stuck doing these, so while this does take a second or two to come back, that's not that bad. Its GENERAL performance that just bites - the system is obviously out of CPU, but what I can't get a handle on is WHY. It does not appear to be accumulating large amounts of runtime in processes I can catch, but the load average is quite high. This is why I'm wondering if what I'm taking here is a hit on the fork/exec inside the portmaster, in the setup internally in there, in the IPC between my process via libPQ, etc - and how I can profile what's going on. Karl Denninger (karl@denninger.net) http://www.denninger.net Tom Lane wrote: > Karl Denninger writes: > >> But.... here's the query that has a habit of taking the most time.... >> > > >> select forum, * from post where toppost = 1 and (replied > (select >> lastview from forumlog where login='theuser' and forum=post.forum and >> number is null)) is not false AND (replied > (select lastview from >> forumlog where login='theuser' and forum=post.forum and >> number=post.number)) is not f >> alse order by pinned desc, replied desc offset 0 limit 20 >> > > Did that ever perform well for you? It's the sub-selects that are > likely to hurt ... in particular, > > >> -> Index Scan using post_top on post (cost=0.00..57266.37 >> rows=113 width=757) >> Index Cond: (toppost = 1) >> Filter: (((replied > (subplan)) IS NOT FALSE) AND >> ((replied > (subplan)) IS NOT FALSE)) >> > > versus > > >> Index Scan using post_top on post (cost=0.00..632.03 rows=1013 width=11) >> Index Cond: (toppost = 1) >> > > The planner thinks that the two subplan filter conditions will eliminate > about 90% of the rows returned by the bare indexscan (IIRC this is > purely a rule of thumb, not based on any statistics) and that testing > them 1013 times will add over 50000 cost units to the basic indexscan. > That part I believe --- correlated subqueries are expensive. > > regards, tom lane > > ---------------------------(end of broadcast)--------------------------- > TIP 5: don't forget to increase your free space map settings > > > %SPAMBLOCK-SYS: Matched [hub.org+], message ok > --------------090003060500060403020307 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Yeah, the problem doesn't appear to be there.  As I said, if I look at the PS of the system when its bogging, there aren't a whole bunch of processes stuck doing these, so while this does take a second or two to come back, that's not that bad.

Its GENERAL performance that just bites - the system is obviously out of CPU, but what I can't get a handle on is WHY.  It does not appear to be accumulating large amounts of runtime in processes I can catch, but the load average is quite high.

This is why I'm wondering if what I'm taking here is a hit on the fork/exec inside the portmaster, in the setup internally in there, in the IPC between my process via libPQ, etc - and how I can profile what's going on.
Karl Denninger (karl@denninger.net)
http://www.denninger.net



Tom Lane wrote:
Karl Denninger <karl@denninger.net> writes:
  
But.... here's the query that has a habit of taking the most time....
    

  
select forum, * from post where toppost = 1 and (replied > (select 
lastview from forumlog where login='theuser' and forum=post.forum and 
number is null)) is not false AND (replied > (select lastview from 
forumlog where login='theuser' and forum=post.forum and 
number=post.number)) is not f
alse order by pinned desc, replied desc offset 0 limit 20
    

Did that ever perform well for you?  It's the sub-selects that are
likely to hurt ... in particular,

  
         ->  Index Scan using post_top on post  (cost=0.00..57266.37 
rows=113 width=757)
               Index Cond: (toppost = 1)
               Filter: (((replied > (subplan)) IS NOT FALSE) AND 
((replied > (subplan)) IS NOT FALSE))
    

versus

  
 Index Scan using post_top on post  (cost=0.00..632.03 rows=1013 width=11)
   Index Cond: (toppost = 1)
    

The planner thinks that the two subplan filter conditions will eliminate
about 90% of the rows returned by the bare indexscan (IIRC this is
purely a rule of thumb, not based on any statistics) and that testing
them 1013 times will add over 50000 cost units to the basic indexscan.
That part I believe --- correlated subqueries are expensive.

			regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings


%SPAMBLOCK-SYS: Matched [hub.org+], message ok
  
--------------090003060500060403020307-- %SPAMBLOCK-SYS: Matched [@postgresql.org+], message ok