Re: cannot use multicolumn index - Mailing list pgsql-performance

From Scott Marlowe
Subject Re: cannot use multicolumn index
Date
Msg-id CAOR=d=3iP-iVahZPS1O1-GAijo=0M_NMrdmM59kkT7Wh-Vgs_w@mail.gmail.com
Whole thread Raw
In response to cannot use multicolumn index  (MirrorX <mirrorx@gmail.com>)
List pgsql-performance
On Wed, Sep 14, 2011 at 6:50 AM, MirrorX <mirrorx@gmail.com> wrote:
> dear all,
>
> i have a table with (approx) 500.000.000 rows. it has several indexes, one
> of which is a multicolumn index
> for a column that has an id (integer) and a column that has a timestamp. i
> have read in the manual that the multicolumn index can be used only if the
> clauses of the query are in the same order as the columns of the index. so i
> am trying the following simple query ->

this is incorrect.  Where did you read this?  The order in the where
clause doesn't matter.  Older versions of pg cannot use a muilticolumn
index unless you use the first column in the where clause / group by,
but newer versions can use that index, but since it's much less
efficient that way they will usually pick another index with the other
column in it first.

pgsql-performance by date:

Previous
From: Gunnlaugur Þór Briem
Date:
Subject: Constraint exclusion on UNION ALL subqueries with WHERE conditions
Next
From: Scott Marlowe
Date:
Subject: Re: cannot use multicolumn index