X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 707CF9FA2CB for ; Wed, 10 May 2006 13:21:53 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 26623-03 for ; Wed, 10 May 2006 13:21:44 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey- Received: from web50306.mail.yahoo.com (web50306.mail.yahoo.com [206.190.38.60]) by postgresql.org (Postfix) with SMTP id 69D029FA293 for ; Wed, 10 May 2006 13:21:44 -0300 (ADT) Received: (qmail 96631 invoked by uid 60001); 10 May 2006 16:21:43 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:Date:From:Subject:To:MIME-Version:Content-Type; b=jmSG8z/egOrIQQ/I8L7zXH/BtMddFTOY/vgNyRWwatHcFuHWHWwM+oCzNC0EMungzQBsckWFqGEvhSVj71d8RPLB0IBkxT7rooWhAMBEDSaE8rvk8i4LQR4aHyXM+gCsm6Pvmzmz9Re4h9Ojemw7s8UaujBo/cMhh6GEqS0kq2o= ; Message-ID: <20060510162143.96628.qmail@web50306.mail.yahoo.com> Date: Wed, 10 May 2006 09:21:43 -0700 (PDT) From: Subject: Multi-column index not used, new flipped column index is To: pgsql-sql@postgresql.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=1.858 tagged_above=0 required=5 tests=BAYES_00, DNS_FROM_RFC_ABUSE, DNS_FROM_RFC_WHOIS, FORGED_YAHOO_RCVD, NO_REAL_NAME X-Spam-Level: * X-Archive-Number: 200605/86 X-Sequence-Number: 25117 Hi, I'm using PG 8.0.3 and recently spotted a query that was not using a multi-column index I had created. The index looks like: CREATE INDEX ..... ON FooTable(fkColumnOne, fkColumnTwo); The query that was not using the index was using: SELECT .... a bunch of columns and joins .... WHERE FooTable.fkColumnTwo=1000; So I added another index where the indexed columns are flipped: CREATE INDEX ..... ON FooTable(fkColumnTwo, fkColumnOne); Now the query started to use that index -- gooooood! But now I have 2 indices that are nearly the same, and that means overhead during INSERTs/DELETEs. :( Is there a way to get this to use that first index, so I don't have to have this additional index? If I had PG 8.1.3, would PG know how to use that first index? I seem to recall something about this somewhere... but I don't see it at http://www.postgresql.org/docs/whatsnew . Thanks, Otis