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 A8AA2565DC for ; Thu, 17 Mar 2005 00:26:09 +0000 (GMT) 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 76833-04 for ; Thu, 17 Mar 2005 00:26:00 +0000 (GMT) Received: from gizmo04bw.bigpond.com (gizmo04bw.bigpond.com [144.140.70.14]) by svr1.postgresql.org (Postfix) with SMTP id 49AB5565DD for ; Thu, 17 Mar 2005 00:25:57 +0000 (GMT) Received: (qmail 3344 invoked from network); 17 Mar 2005 00:25:58 -0000 Received: from unknown (HELO bwmam05.bigpond.com) (144.135.24.81) by gizmo04bw.bigpond.com with SMTP; 17 Mar 2005 00:25:58 -0000 Received: from cpe-203-45-203-73.qld.bigpond.net.au ([203.45.203.73]) by bwmam05.bigpond.com(MAM REL_3_4_2a 44/8555369) with SMTP id 8555369; Thu, 17 Mar 2005 10:25:58 +1000 Message-ID: <4238CE87.1040904@bigpond.net.au> Date: Thu, 17 Mar 2005 10:25:43 +1000 From: David Brown User-Agent: Mozilla Thunderbird 1.0RC1 (Windows/20041201) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Josh Berkus Subject: Re: multi-column index References: <42385A1B.9090305@ibcp.fr> <200503161009.24713.josh@agliodbs.com> In-Reply-To: <200503161009.24713.josh@agliodbs.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.728 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_ABUSE, DNS_FROM_RFC_WHOIS X-Spam-Level: X-Archive-Number: 200503/344 X-Sequence-Number: 11049 Whoa Josh! I don't believe you're going to reduce the cost by 10 times through a bit of tweaking - not without lowering the sequential scan cost as well. The only thing I can think of is perhaps his primary index drastically needs repacking. Otherwise, isn't there a real anomaly here? Halving the key width might account for some of it, but it's still miles out of court. Actually, I'm surprised the planner came up with such a low cost for the single column index, unless ... perhaps correlation statistics aren't used when determining costs for multi-column indexes? Josh Berkus wrote: >Pretty simple, really. Look at the cost calculations for the index scan for >the multi-column index. PostgreSQL believes that: >The cost of a seq scan is 4788.14 >The cost of an 2-column index scan is 36720.39 >The cost of a 1-column index scan is 916.24 > >Assuming that you ran each of these queries multiple times to eliminate >caching as a factor, the issue is that the cost calculations are wrong. We >give you a number of GUC variables to change that: >effective_cache_size >random_page_cost >cpu_tuple_cost >etc. > >See the RUNTIME-CONFIGURATION docs for more details. >