X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id A69E352837 for ; Thu, 26 May 2005 15:31:59 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 00619-08 for ; Thu, 26 May 2005 18:31:57 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 99C4C52824 for ; Thu, 26 May 2005 15:31:56 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j4QIVvW4004063; Thu, 26 May 2005 14:31:57 -0400 (EDT) To: "Brad Might" Cc: pgsql-performance@postgresql.org Subject: Re: Specific query performance problem help requested - postgresql 7.4 In-reply-to: References: Comments: In-reply-to "Brad Might" message dated "Thu, 26 May 2005 12:55:32 -0500" Date: Thu, 26 May 2005 14:31:57 -0400 Message-ID: <4062.1117132317@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/400 X-Sequence-Number: 12564 "Brad Might" writes: > Can someone help me break this down and figure out why the one query > takes so much longer than the other? It looks to me like there's a correlation between filename and bucket, such that the indexscan in filename order takes much longer to run across the first 25 rows with bucket = 3 than it does to run across the first 25 with bucket = 7 or bucket = 8. It's not just a matter of there being fewer rows with bucket = 3 ... the cost differential is much larger than is explained by the count ratios. The bucket = 3 rows have to be lurking further to the back of the filename order than the others. > Here's the bucket distribution..i have clustered the index on the bucket > value. If you have an index on bucket, it's not doing you any good here anyway, since you wrote the constraint as a crosstype operator ("3" is int4 not int8). It might help to explicitly cast the constant to int8. regards, tom lane