X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id E96E9D1B93F for ; Thu, 21 Aug 2003 13:25:39 -0300 (ADT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 67704-01 for ; Thu, 21 Aug 2003 13:25:09 -0300 (ADT) Received: from www.postgresql.com (www.postgresql.com [64.117.225.209]) by svr1.postgresql.org (Postfix) with ESMTP id 0B520D1B921 for ; Thu, 21 Aug 2003 13:25:09 -0300 (ADT) Received: from sojef.skynet.be (sojef.skynet.be [195.238.2.127]) by www.postgresql.com (Postfix) with ESMTP id 5C8C2CF4BC8 for ; Thu, 21 Aug 2003 13:25:08 -0300 (ADT) Received: from pleyel.kotnet.org (157.77-200-80.adsl.skynet.be [80.200.77.157]) by sojef.skynet.be (8.12.9/8.12.9/Skynet-OUT-2.21) with ESMTP id h7LGOgdu007480; Thu, 21 Aug 2003 18:24:42 +0200 (envelope-from ) Received: from slicks by pleyel.kotnet.org with local (Exim 3.36 #1 (Debian)) id 19psEy-0002ha-00; Thu, 21 Aug 2003 18:24:48 +0200 Date: Thu, 21 Aug 2003 18:24:48 +0200 From: Mathieu De Zutter To: Tom Lane Cc: pgsql-performance@postgresql.org Subject: Re: Sorting a query on a view ignores an index Message-ID: <20030821162448.GC973@pleyel.kotnet.org> Reply-To: Mathieu De Zutter References: <20030821133538.GA973@pleyel.kotnet.org> <8509.1061477951@sss.pgh.pa.us> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <8509.1061477951@sss.pgh.pa.us> User-Agent: Mutt/1.5.4i X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200308/304 X-Sequence-Number: 3120 On Thu, Aug 21, 2003 at 10:59:11AM -0400, Tom Lane wrote: > Mathieu De Zutter writes: > > However, i dont want the view to be presorted, but sort it in the > > queries that use the view. When I do that, the index I have on that > > field seems to be ignored. It stretches so far that, when I sort the > > view on A and sort the query on A too, the query will try to sort > > _again_ _without_ index and thus lose all performance. > > This is a limitation of the 7.3 query planner. 7.4 should do better. Ok I'll have to live with that I guess. Apart from avoiding views or subselects when sorting afterwards and putting the whole bunch in a huge SQL statement (which i'll have to produce on-the-fly), do you have an other alternative? The 2 seconds is way to much, as the database will eventually run on a machine that is 10 times slower. With kind regards, Mathieu