On Thu, Oct 1, 2009 at 10:04 PM, Chris <dmagick(at)gmail(dot)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(dot)t(dot)wilson(at)gmail(dot)com