Re: How to force PostgreSQL using an index - Mailing list pgsql-sql

From Daniel Caune
Subject Re: How to force PostgreSQL using an index
Date
Msg-id 1E293D3FF63A3740B10AD5AAD88535D20190944D@UBIMAIL1.ubisoft.org
Whole thread Raw
In response to How to force PostgreSQL using an index  ("Daniel Caune" <daniel.caune@ubisoft.com>)
List pgsql-sql

> -----Message d'origine-----
> De : Tom Lane [mailto:tgl@sss.pgh.pa.us]
> Envoyé : mercredi, février 15, 2006 17:47
> À : Daniel Caune
> Cc : Andrew Sullivan; pgsql-sql@postgresql.org
> Objet : Re: [SQL] How to force PostgreSQL using an index
>
> "Daniel Caune" <daniel.caune@ubisoft.com> writes:
> > SELECT <some-columns>
> >   FROM GSLOG_EVENT
> >   WHERE EVENT_NAME = 'player-status-update'
> >     AND EVENT_DATE_CREATED >= <start-time>
> >     AND EVENT_DATE_CREATED < <end-time>
>
> > I have an index on EVENT_DATE_CREATED that does it job.  But I though
> > that I can help my favourite PostgreSQL if I create a composite index on
> > EVENT_DATE_CREATED and EVENT_NAME (in that order as EVENT_DATE_CREATED
> > is more dense that EVENT_NAME).
>
> Wrong ... should be EVENT_NAME first.  Think about the sort order of the
> data to see why --- your query represents a contiguous subset of the
> index if EVENT_NAME is first, but not if EVENT_DATE_CREATED is first.
>
>             regards, tom lane

Yes, you're right!


pgsql-sql by date:

Previous
From: Markus Schaber
Date:
Subject: Re: VIEWs and TEMP tables problem
Next
From: Tom Lane
Date:
Subject: Re: VIEWs and TEMP tables problem