X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 8A52B9DC99E for ; Tue, 17 Jan 2006 18:57:11 -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 54541-10 for ; Tue, 17 Jan 2006 18:57:13 -0400 (AST) Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) by postgresql.org (Postfix) with ESMTP id 5F4DE9DC80F for ; Tue, 17 Jan 2006 18:57:09 -0400 (AST) Received: from electronsrus.com (adsl-69-154-123-204.dsl.fyvlar.swbell.net [69.154.123.204]) by svr4.postgresql.org (Postfix) with ESMTP id 86A435AF05E for ; Tue, 17 Jan 2006 22:57:12 +0000 (GMT) Received: from bits.electronsrus.com (bits.electronsrus.com [70.178.169.136]) (authenticated bits=0) by electronsrus.com (8.13.4/8.13.4/Debian-2) with ESMTP id k0HMvEwn023036; Tue, 17 Jan 2006 16:57:15 -0600 From: Fredrick O Jackson To: pgsql-performance@postgresql.org Subject: Re: Multiple Order By Criteria Date: Tue, 17 Jan 2006 16:57:06 -0600 User-Agent: KMail/1.8.3 Cc: J@planeti.biz References: <05c301c61bb1$d88c6a00$681e140a@fatchubby> <200601171425.38772.josh@agliodbs.com> <05d801c61bb5$6c8824d0$681e140a@fatchubby> In-Reply-To: <05d801c61bb5$6c8824d0$681e140a@fatchubby> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200601171657.06542@bits.electronsrus.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.585 required=5 tests=[AWL=-0.585, BIZ_TLD=1.169] X-Spam-Score: 0.585 X-Spam-Level: X-Archive-Number: 200601/275 X-Sequence-Number: 16753 try adding the keyword 'date' before the date in your query. I ran into this quite a while back, but I'm not sure I remember the solution. > In Reply to: Tuesday January 17 2006 04:29 pm, J@planeti.biz J@planeti.biz wrote: > I created the index, in order. Did a vacuum analyze on the table and my > explain still says: > > Limit (cost=229610.78..229611.03 rows=100 width=717) > -> Sort (cost=229610.78..230132.37 rows=208636 width=717) > Sort Key: receipt, carrier_id, batchnum, encounternum, encounter_id > -> Seq Scan on detail_summary ds (cost=0.00..22647.13 rows=208636 > width=717) > Filter: (receipt >= '2004-03-22'::date) > > > So, for fun I did > set enable_seqscan to off > > But that didn't help. For some reason, the sort wants to do a seq scan and > not use my super new index. > > Am I doing something wrong ? > > ----- Original Message ----- > From: "Josh Berkus" > To: > Cc: > Sent: Tuesday, January 17, 2006 5:25 PM > Subject: Re: [PERFORM] Multiple Order By Criteria > > > J, > > > >> I have an index built for each of these columns in my order by clause. > >> This query takes an unacceptable amount of time to execute. Here are the > >> results of the explain: > > > > You need a single index which has all five columns, in order. > > > > > > -- > > --Josh > > > > Josh Berkus > > Aglio Database Solutions > > San Francisco > > > > ---------------------------(end of broadcast)--------------------------- > > TIP 1: if posting/reading through Usenet, please send an appropriate > > subscribe-nomail command to majordomo@postgresql.org so that your > > message can get through to the mailing list cleanly > > ---------------------------(end of broadcast)--------------------------- > TIP 4: Have you searched our list archives? > > http://archives.postgresql.org