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 26123D8B60 for ; Wed, 9 Nov 2005 08:08:44 -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 17356-03 for ; Wed, 9 Nov 2005 12:08:39 +0000 (GMT) X-Greylist: delayed 01:05:09.043067 by SQLgrey- Received: from h6608.serverkompetenz.net (gpg-keyserver.de [81.169.179.29]) by svr1.postgresql.org (Postfix) with ESMTP id 93DD4D70C0 for ; Wed, 9 Nov 2005 08:08:40 -0400 (AST) Received: from [217.186.218.187] (helo=[192.168.0.51]) by h6608.serverkompetenz.net with asmtp (Exim 4.34) id 1EZoks-0002Hz-7m for pgsql-performance@postgresql.org; Wed, 09 Nov 2005 13:08:42 +0100 Message-ID: <4371E6A7.50808@web.de> Date: Wed, 09 Nov 2005 13:08:07 +0100 From: Jan Kesten User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317) X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Improving performance on multicolumn query X-Enigmail-Version: 0.92.0.0 OpenPGP: id=82201FC4; url=http://gpg-keyserver.de Content-Type: multipart/mixed; boundary="------------050207070808000904010206" X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0 required=5 tests=[none] X-Spam-Score: 0 X-Spam-Level: X-Archive-Number: 200511/153 X-Sequence-Number: 15410 This is a multi-part message in MIME format. --------------050207070808000904010206 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Hi, all! I've been using postgresql for a long time now, but today I had some problem I couldn't solve properly - hope here some more experienced users have some hint's for me. First, I'm using postgresql 7.4.7 on a 2GHz machine having 1.5GByte RAM and I have a table with about 220 columns and 20000 rows - and the first five columns build a primary key (and a unique index). 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)) 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. Accidently I can't refactor these tables as they were given to me. Thanks for any hint! Jan --------------050207070808000904010206 Content-Type: application/pgp-signature; name="signature.asc" Content-Transfer-Encoding: base64 Content-Disposition: inline; filename="signature.asc" LS0tLS1CRUdJTiBQR1AgU0lHTkFUVVJFLS0tLS0NClZlcnNpb246IEdudVBHIHYxLjIuNCAo TWluZ1czMikNCkNvbW1lbnQ6IFVzaW5nIEdudVBHIHdpdGggVGh1bmRlcmJpcmQgLSBodHRw Oi8vZW5pZ21haWwubW96ZGV2Lm9yZw0KDQppRDhEQlFGRGNkZGV2dm1Da0lJZ0g4UVJBc3lX QUo0M1BGVUhCdmVlanBCTk1hRC9DczgwdjBnb1RnQ2dyMTZaDQprNUVuWEtKZDZQZjE4eHRi dEY1Y05uUT0NCj1wWmJvDQotLS0tLUVORCBQR1AgU0lHTkFUVVJFLS0tLS0NCg0K --------------050207070808000904010206--