Re: Query not using the indexes properly. - Mailing list pgsql-general

From David Wilson
Subject Re: Query not using the indexes properly.
Date
Msg-id e7f9235d0910011918s575cdd70mca1ea1fa61a7c5e1@mail.gmail.com
Whole thread Raw
In response to Re: Query not using the indexes properly.  (Chris <dmagick@gmail.com>)
Responses Re: Query not using the indexes properly.
List pgsql-general


On Thu, Oct 1, 2009 at 10:04 PM, Chris <dmagick@gmail.com> wrote:
Tim Uckun wrote:

If this is a common query you could probably do a multi-column index on all 3 columns (id, company_id, source_model_name) - but if company_id and source_model_name have a low number of distinct values, then it's not going to help.

If you try the multi-column index (which is a good idea), be sure that "id" is the last of the three columns, since that's the column on which you have an inequality test rather than an equality test; eg, (company_id,source_model_name,id).

--
- David T. Wilson
david.t.wilson@gmail.com

pgsql-general by date:

Previous
From: Chris
Date:
Subject: Re: Query not using the indexes properly.
Next
From: Tim Uckun
Date:
Subject: Re: Query not using the indexes properly.