Received: from bush.rutgersinsurance.com (rutgersinsurance.com [38.138.71.194]) by mail.postgresql.org (8.11.1/8.11.1) with ESMTP id f18GOTx98165 for ; Thu, 8 Feb 2001 11:24:29 -0500 (EST) (envelope-from aalang@rutgersinsurance.com) Received: from 6014cwpza006 (adam.rutgersinsurance.com [10.10.10.51]) by bush.rutgersinsurance.com (8.9.3/8.9.3) with SMTP id LAA23852 for ; Thu, 8 Feb 2001 11:27:49 -0500 Message-ID: <013a01c091eb$d4e20c20$330a0a0a@rutgersinsurance.com> From: "Adam Lang" To: "PostgreSQL PHP" References: <20010208154156.9447813AB5@ml-samba.mdc.mlhs.org> Subject: Re: Fooling the query optimizer Date: Thu, 8 Feb 2001 11:26:03 -0500 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4133.2400 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 X-Archive-Number: 200102/9 X-Sequence-Number: 148 Let me look into this. Adam Lang Systems Engineer Rutgers Casualty Insurance Company http://www.rutgersinsurance.com ----- Original Message ----- From: "Brent R.Matzelle" To: "PostgreSQL PHP" Sent: Thursday, February 08, 2001 10:41 AM Subject: [PHP] Fooling the query optimizer > 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