X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (neptune.hub.org [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 3B904D1DAAE for ; Mon, 26 Jan 2004 20:53:55 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 24290-08 for ; Mon, 26 Jan 2004 16:53:25 -0400 (AST) Received: from front1.mail.megapathdsl.net (front1.mail.megapathdsl.net [66.80.60.31]) by svr1.postgresql.org (Postfix) with ESMTP id BC369D1DAA7 for ; Mon, 26 Jan 2004 16:53:22 -0400 (AST) Received: from [64.32.131.193] (HELO [192.168.1.11]) by front1.mail.megapathdsl.net (CommuniGate Pro SMTP 4.1.3) with ESMTP id 142014084; Mon, 26 Jan 2004 12:53:16 -0800 Subject: Re: help with dual indexing From: Orion Henry To: Tom Lane Cc: pgsql-performance@postgresql.org In-Reply-To: <8630.1074906490@sss.pgh.pa.us> References: <1074884311.10503.133.camel@orthanc> <8630.1074906490@sss.pgh.pa.us> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-/SGFZCJoVJ3vp35S0DRf" Organization: Message-Id: <1075150396.10503.363.camel@orthanc> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.2 (1.2.2-5) Date: 26 Jan 2004 12:53:16 -0800 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200401/275 X-Sequence-Number: 5449 --=-/SGFZCJoVJ3vp35S0DRf Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Thanks Tom! You're a life-saver. On Fri, 2004-01-23 at 17:08, Tom Lane wrote: > Orion Henry writes: > > The queries usually are in the form of, where "user_id =3D something and > > event_time between something and something". >=20 > > Half of my queries index off of the user_id and half index off the > > event_time. I was thinking this would be a perfect opportunity to use a > > dual index of (user_id,event_time) but I'm confused as to weather this > > will help >=20 > Probably. Put the user_id as the first column of the index --- if you > think about the sort ordering of a multicolumn index, you will see why. > With user_id first, a constraint as above describes a contiguous > subrange of the index; with event_time first it does not. >=20 > regards, tom lane --=20 Orion Henry --=-/SGFZCJoVJ3vp35S0DRf Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (GNU/Linux) iD8DBQBAFX489IoQcq23xtARAuCOAJ9k8n1ra4QsuMeC3mhGXsRGrng2aACgg08J XQWJWgGbCY6bLcSF6lQtgp8= =tCBy -----END PGP SIGNATURE----- --=-/SGFZCJoVJ3vp35S0DRf--