Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id E9AEF64FCCE for ; Sat, 9 Aug 2008 03:21:40 -0300 (ADT) Received: from postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 28033-02 for ; Sat, 9 Aug 2008 03:21:22 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from smtp.01.com (lb-2.01.com [38.98.186.147]) by postgresql.org (Postfix) with ESMTP id EFF2965019E for ; Sat, 9 Aug 2008 03:17:42 -0300 (ADT) Received: from asav-2.01.com (localhost.localdomain [127.0.0.1]) by asav-2.01.com (8.13.1/8.13.1) with SMTP id m796HPnA028979; Sat, 9 Aug 2008 01:17:25 -0500 Received: from smtp-1.01.com (smtp-1.01.com [38.98.186.157]) by asav-2.01.com (asav-2.01.com [10.25.1.12]) id k781HP2278855779Lm ret-id none; Sat, 09 Aug 2008 01:17:25 -0500 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp-1.01.com (Postfix) with ESMTP id 449A3E0201; Sat, 9 Aug 2008 01:17:25 -0500 (CDT) Received: from smtp-1.01.com ([127.0.0.1]) by localhost (smtp-1.01.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id cNIbfDjkUhpC; Sat, 9 Aug 2008 01:17:25 -0500 (CDT) Received: from [10.10.10.18] (adsl-69-226-235-55.dsl.pltn13.pacbell.net [69.226.235.55]) by smtp-1.01.com (Postfix) with ESMTP id 79F5BE00EC; Sat, 9 Aug 2008 01:17:24 -0500 (CDT) Message-ID: <489D3673.5080100@frostconsultingllc.com> Date: Fri, 08 Aug 2008 23:17:23 -0700 From: Jeff Frost Organization: Frost Consulting, LLC User-Agent: Thunderbird 2.0.0.16 (Windows/20080708) MIME-Version: 1.0 To: Tom Lane CC: pgsql-performance@postgresql.org Subject: Re: index scan cost References: <9919.1216355851@sss.pgh.pa.us> In-Reply-To: <9919.1216355851@sss.pgh.pa.us> Content-Type: multipart/alternative; boundary="------------030706050202020606070502" X-FSL-MailScanner-Information: Please contact postmaster@01.com for more information X-FSL-MailScanner: Found to be clean X-FSL-MailScanner-SpamCheck: X-FSL-MailScanner-From: jeff@frostconsultingllc.com X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.001 tagged_above=0 required=5 tests=HTML_MESSAGE=0.001 X-Spam-Level: X-Archive-Number: 200808/83 X-Sequence-Number: 30964 This is a multi-part message in MIME format. --------------030706050202020606070502 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Tom Lane wrote: > Jeff Frost writes: > >> I have two postgresql servers. One runs 8.3.1, the other 8.3.3. On the 8.3.1 >> machine, the index scans are being planned extremely low cost: >> > > >> Index Scan using ix_email_entity_thread on email_entity (cost=0.00..4.59 >> rows=1 width=1031) (actual time=0.095..0.120 rows=4 loops=1) >> Index Cond: (email_thread = 375629157) >> > > >> Index Scan using ix_email_entity_thread on email_entity (cost=0.00..2218.61 >> rows=1151 width=931) (actual time=0.094..0.111 rows=4 loops=1) >> Index Cond: (email_thread = 375629157) >> > > This isn't a "cost" problem, this is a "stats" problem. Why does the > second server think 1151 rows will be returned? Try comparing the > pg_stats entries for the email_thread column on both servers ... seems > like they must be significantly different. > Sorry it took me a while to close the loop on this. So, the server that had the less desirable plan had actually been analyzed more recently by autovacuum. When I went back to compare the stats on the faster server, autovacuum had analyzed it and the plan was now more similar. Adjusting the stats target up for that column helped on both servers though it never did get back as close as before. -- Jeff Frost, Owner Frost Consulting, LLC http://www.frostconsultingllc.com/ Phone: 916-647-6411 FAX: 916-405-4032 --------------030706050202020606070502 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Tom Lane wrote:
Jeff Frost <jeff@frostconsultingllc.com> writes:
  
I have two postgresql servers.  One runs 8.3.1, the other 8.3.3.  On the 8.3.1 
machine, the index scans are being planned extremely low cost:
    

  
  Index Scan using ix_email_entity_thread on email_entity  (cost=0.00..4.59 
rows=1 width=1031) (actual time=0.095..0.120 rows=4 loops=1)
    Index Cond: (email_thread = 375629157)
    

  
  Index Scan using ix_email_entity_thread on email_entity  (cost=0.00..2218.61 
rows=1151 width=931) (actual time=0.094..0.111 rows=4 loops=1)
    Index Cond: (email_thread = 375629157)
    

This isn't a "cost" problem, this is a "stats" problem.  Why does the
second server think 1151 rows will be returned?  Try comparing the
pg_stats entries for the email_thread column on both servers ... seems
like they must be significantly different.
  
Sorry it took me a while to close the loop on this.  So, the server that had the less desirable plan had actually been analyzed more recently by autovacuum.  When I went back to compare the stats on the faster server, autovacuum had analyzed it and the plan was now more similar.  Adjusting the stats target up for that column helped on both servers though it never did get back as close as before.

-- 
Jeff Frost, Owner 	<jeff@frostconsultingllc.com>
Frost Consulting, LLC 	http://www.frostconsultingllc.com/
Phone: 916-647-6411	FAX: 916-405-4032
--------------030706050202020606070502--