Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 2BDC163259F for ; Tue, 17 Aug 2010 00:33:37 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 69827-02 for ; Tue, 17 Aug 2010 03:33:30 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mail.postgresql.org (Postfix) with ESMTP id 1D1AE6322C3 for ; Tue, 17 Aug 2010 00:33:30 -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 o7H3XTF4029299; Mon, 16 Aug 2010 23:33:29 -0400 (EDT) To: "Benjamin Krajmalnik" cc: pgsql-performance@postgresql.org Subject: Re: Quesion on the use of indexes In-reply-to: References: Comments: In-reply-to "Benjamin Krajmalnik" message dated "Mon, 16 Aug 2010 21:22:57 -0600" Date: Mon, 16 Aug 2010 23:33:29 -0400 Message-ID: <29298.1282016009@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-10 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201008/169 X-Sequence-Number: 40012 "Benjamin Krajmalnik" writes: > A little background - I have various multi-column indexes whenever I > have queries which restrict the output based on the values of the 2 > fields (for example, a client code and the date of a transaction). > Is there a performance gain using this approach as opposed to using 2 > separate indexes, one on the first column and one on the second column? Maybe, maybe not ... it's going to depend on a bunch of factors, one of which is what your update load is like compared to the queries that read the indexes. There's a bit of coverage of this in the fine manual: see http://www.postgresql.org/docs/8.4/static/indexes-multicolumn.html and the next few pages. The short of it is that there's no substitute for doing your own experiments for your own application ... regards, tom lane