Received: from ml-samba.mdc.mlhs.org (mdc-external-proxy.mlhs.org [192.104.254.70]) by mail.postgresql.org (8.11.1/8.11.1) with ESMTP id f18FhFx93792 for ; Thu, 8 Feb 2001 10:43:15 -0500 (EST) (envelope-from bmatzelle@yahoo.com) Received: from ML-MATZEB (ML-MATZEB.mdc.mlhs.org [10.101.23.143]) by ml-samba.mdc.mlhs.org (Postfix) with SMTP id 9447813AB5 for ; Thu, 8 Feb 2001 10:41:56 -0500 (EST) Date: Thu, 08 Feb 2001 10:41:59 -0500 To: PostgreSQL PHP From: "Brent R.Matzelle" Subject: Fooling the query optimizer X-Mailer: Opera 5.02 build 855 X-Priority: 3 (Normal) Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Message-Id: <20010208154156.9447813AB5@ml-samba.mdc.mlhs.org> X-Archive-Number: 200102/8 X-Sequence-Number: 147 Have any of you discovered a way to get around the current query optimizer limitation in Postgres? For example, I have a table that has three columns that I want to index for frequent search duties. In Postgres I am forced to create three indicies: one including all three columns, one for col2 and col3, and one for just col3. Databases like MySQL can use the first index for these types of queries "SELECT * WHERE col2 = x AND col3 = y" and "SELECT * WHERE col3 = y". Postgres could only perform queries on indicies where it looks like "SELECT * WHERE col1 = x AND col2 = y AND col3 = z" and "SELECT * WHERE col1 = x AND col2 = y" etc. However adding extra indexes as above would decrease the write speed on that table because a simple insert would require an update on all three indicies. Is there a way to fool Postgres to use the first index by creating a query like "SELECT * WHERE col1 = * AND col3 = x"? I know I'm grasping for straws here, but these issues can kill my database query performance. Brent