X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id ADD5F9DCA02 for ; Thu, 16 Feb 2006 09:57:19 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 97447-07 for ; Thu, 16 Feb 2006 09:57:23 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from relay01.mdc.ubisoft.com (relay01.mdc.ubisoft.com [216.98.56.134]) by postgresql.org (Postfix) with ESMTP id A30779DCA25 for ; Thu, 16 Feb 2006 09:57:17 -0400 (AST) Received: from mdc-owa01.ubisoft.org (srvowa1-mdc.ubisoft.org [10.129.1.20]) by smarthost.mdc.ubisoft.com (Postfix) with ESMTP id 23E014BC69; Thu, 16 Feb 2006 08:57:21 -0500 (EST) Received: from UBIMAIL1.ubisoft.org ([10.129.1.15]) by mdc-owa01.ubisoft.org with Microsoft SMTPSVC(6.0.3790.1830); Thu, 16 Feb 2006 08:57:20 -0500 X-MimeOLE: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Subject: Re: How to force PostgreSQL using an index Date: Thu, 16 Feb 2006 08:57:20 -0500 Message-ID: <1E293D3FF63A3740B10AD5AAD88535D20190944D@UBIMAIL1.ubisoft.org> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [SQL] How to force PostgreSQL using an index Thread-Index: AcYygclrsU7Ywy1NTbWP282TUbZ6lQAfkvYw From: "Daniel Caune" To: "Tom Lane" Cc: "Andrew Sullivan" , X-OriginalArrivalTime: 16 Feb 2006 13:57:20.0942 (UTC) FILETIME=[E7D91CE0:01C63300] X-Ubisoft-MailScanner-Information: Please contact administrators@ubisoft.qc.ca X-Ubisoft-MailScanner: Found to be clean X-Ubisoft-MailScanner-SpamCheck: X-MailScanner-From: daniel.caune@ubisoft.com X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.122 required=5 tests=[AWL=0.122, UPPERCASE_25_50=0] X-Spam-Score: 0.122 X-Spam-Level: X-Archive-Number: 200602/204 X-Sequence-Number: 24214 > -----Message d'origine----- > De=A0: Tom Lane [mailto:tgl@sss.pgh.pa.us] > Envoy=E9=A0: mercredi, f=E9vrier 15, 2006 17:47 > =C0=A0: Daniel Caune > Cc=A0: Andrew Sullivan; pgsql-sql@postgresql.org > Objet=A0: Re: [SQL] How to force PostgreSQL using an index >=20 > "Daniel Caune" writes: > > SELECT > > FROM GSLOG_EVENT > > WHERE EVENT_NAME =3D 'player-status-update' > > AND EVENT_DATE_CREATED >=3D > > AND EVENT_DATE_CREATED < >=20 > > 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). >=20 > 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. >=20 > regards, tom lane Yes, you're right!