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 8F153D9B47 for ; Wed, 9 Nov 2005 11:51:47 -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 82118-02 for ; Wed, 9 Nov 2005 15:51:41 +0000 (GMT) X-Greylist: delayed 03:07:14.708408 by SQLgrey- Received: from svr2.postgresql.org (svr2.postgresql.org [65.19.161.25]) by svr1.postgresql.org (Postfix) with ESMTP id C227ED967B for ; Wed, 9 Nov 2005 11:51:41 -0400 (AST) Received: from cassarossa.samfundet.no (cassarossa.samfundet.no [129.241.93.19]) by svr2.postgresql.org (Postfix) with ESMTP id 53B3BF0F48 for ; Wed, 9 Nov 2005 12:44:30 +0000 (GMT) Received: from trofast.sesse.net ([129.241.93.32]) by cassarossa.samfundet.no with esmtp (Exim 4.50) id 1EZpJQ-0002LS-SO for pgsql-performance@postgresql.org; Wed, 09 Nov 2005 13:44:26 +0100 Received: from sesse by trofast.sesse.net with local (Exim 3.36 #1 (Debian)) id 1EZpJV-0002Nd-00 for ; Wed, 09 Nov 2005 13:44:29 +0100 Date: Wed, 9 Nov 2005 13:44:29 +0100 From: "Steinar H. Gunderson" To: pgsql-performance@postgresql.org Subject: Re: Improving performance on multicolumn query Message-ID: <20051109124429.GA9127@uio.no> Mail-Followup-To: pgsql-performance@postgresql.org References: <4371E6A7.50808@web.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <4371E6A7.50808@web.de> X-Operating-System: Linux 2.6.14 on a i686 X-Message-Flag: Outlook? --> http://www.mozilla.org/products/thunderbird/ User-Agent: Mutt/1.5.11 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.009 required=5 tests=[AWL=0.009] X-Spam-Score: 0.009 X-Spam-Level: X-Archive-Number: 200511/157 X-Sequence-Number: 15414 On Wed, Nov 09, 2005 at 01:08:07PM +0100, Jan Kesten wrote: > Now my problem: I need really many queries of rows using it's primary > key and fetching about five different columns but these are quite slow > (about 10 queries per second and as I have some other databases which > can have about 300 queries per second I think this is slow): > > 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)) You don't post your table definitions (please do), but it looks like test_b, test_c, test_d and test_e might be bigints? If so, you may want to do explicit "AND test_b=1::bigint AND test_c=2::bigint" etc. -- 7.4 doesn't figure this out for you. (8.0 and higher does.) /* Steinar */ -- Homepage: http://www.sesse.net/