X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 7957FD964B for ; Wed, 9 Nov 2005 09:19:37 -0400 (AST) 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 36670-03 for ; Wed, 9 Nov 2005 13:19:33 +0000 (GMT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from svr2.postgresql.org (svr2.postgresql.org [65.19.161.25]) by svr1.postgresql.org (Postfix) with ESMTP id 80650D95C1 for ; Wed, 9 Nov 2005 09:19:35 -0400 (AST) Received: from vscan01.westnet.com.au (vscan01.westnet.com.au [203.10.1.131]) by svr2.postgresql.org (Postfix) with ESMTP id CEB4CF0BD7 for ; Wed, 9 Nov 2005 13:19:38 +0000 (GMT) Received: from localhost (localhost.localdomain [127.0.0.1]) by localhost (Postfix) with ESMTP id 4E824760373; Wed, 9 Nov 2005 21:19:34 +0800 (WST) Received: from vscan01.westnet.com.au ([127.0.0.1]) by localhost (vscan01.westnet.com.au [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 12370-11; Wed, 9 Nov 2005 21:19:34 +0800 (WST) Received: from [202.72.133.22] (dsl-202-72-133-22.wa.westnet.com.au [202.72.133.22]) by vscan01.westnet.com.au (Postfix) with ESMTP id C32C576035D; Wed, 9 Nov 2005 21:19:33 +0800 (WST) Message-ID: <4371F765.1050209@familyhealth.com.au> Date: Wed, 09 Nov 2005 21:19:33 +0800 From: Christopher Kings-Lynne User-Agent: Mozilla Thunderbird 1.0.7 (Windows/20050923) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Jan Kesten Cc: pgsql-performance@postgresql.org Subject: Re: Improving performance on multicolumn query References: <4371E6A7.50808@web.de> In-Reply-To: <4371E6A7.50808@web.de> 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, score=0.011 required=5 tests=[AWL=0.011] X-Spam-Score: 0.011 X-Spam-Level: X-Archive-Number: 200511/156 X-Sequence-Number: 15413 > transfer=> explain analyse SELECT * FROM test WHERE test_a=9091150001 > AND test_b=1 AND test_c=2 AND test_d=0 AND test_e=0; > > Index Scan using test_idx on test (cost=0.00..50.27 rows=1 width=1891) > (actual time=0.161..0.167 rows=1 loops=1) > Index Cond: (test_a = 9091150001::bigint) > Filter: ((test_b = 1) AND (test_c = 2) AND (test_d = 0) AND (test_e 0)) > > So, what to do to speed things up? If I understand correctly this > output, the planner uses my index (test_idx is the same as test_pkey > created along with the table), but only for the first column. Hi Jan, If you're using 7.4.x then the planner can't use the index for unquoted bigints. Try this: SELECT * FROM test WHERE test_a='9091150001' AND test_b='1' AND test_c=''2 AND test_d='0' AND test_e='0'; Chris