Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 7813EB5D803 for ; Mon, 31 Oct 2011 15:59:28 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 89748-06 for ; Mon, 31 Oct 2011 18:59:22 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.8.0-rc2 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mail.postgresql.org (Postfix) with ESMTP id 6A840B5DC35 for ; Mon, 31 Oct 2011 15:59:21 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id p9VIxK1H005181; Mon, 31 Oct 2011 14:59:20 -0400 (EDT) To: Claudio Freire cc: Robert Haas , Carlo Stonebanks , pgsql-performance@postgresql.org Subject: Re: Composite keys In-reply-to: References: Comments: In-reply-to Claudio Freire message dated "Mon, 31 Oct 2011 14:52:14 -0300" Date: Mon, 31 Oct 2011 14:59:19 -0400 Message-ID: <5180.1320087559@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-3.101 tagged_above=-10 required=5 tests=BAYES_00=-1.9, RP_MATCHES_RCVD=-1.201 X-Spam-Level: X-Archive-Number: 201110/288 X-Sequence-Number: 45510 Claudio Freire writes: > On Mon, Oct 31, 2011 at 2:08 PM, Robert Haas wrote: >>> Multicolumn indices on (c1, c2, ..., cn) can only be used on where >>> clauses involving c1..ck with k> I don't think that's true.  I believe it can be used for a query that >> only touches, say, c2.  It's just extremely inefficient. > Does postgres generate those kinds of plans? Sure it does. It doesn't usually think they're efficient enough, because they require full-index scans. But sometimes that's the best you can do. regards, tom lane