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 E58E8D1E868 for ; Sat, 24 Jan 2004 01:08:39 +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 32875-01 for ; Fri, 23 Jan 2004 21:08:11 -0400 (AST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id 90AFAD1D8DA for ; Fri, 23 Jan 2004 21:08:07 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.10/8.12.10) with ESMTP id i0O18ApH008631; Fri, 23 Jan 2004 20:08:10 -0500 (EST) To: Orion Henry Cc: pgsql-performance@postgresql.org Subject: Re: help with dual indexing In-reply-to: <1074884311.10503.133.camel@orthanc> References: <1074884311.10503.133.camel@orthanc> Comments: In-reply-to Orion Henry message dated "23 Jan 2004 10:58:31 -0800" Date: Fri, 23 Jan 2004 20:08:10 -0500 Message-ID: <8630.1074906490@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200401/250 X-Sequence-Number: 5424 Orion Henry writes: > The queries usually are in the form of, where "user_id = something and > event_time between something and something". > 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 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. regards, tom lane