X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 38E09D9447 for ; Fri, 4 Nov 2005 10:47:58 -0400 (AST) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 90536-10 for ; Fri, 4 Nov 2005 14:47:54 +0000 (GMT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 2B3F8D9435 for ; Fri, 4 Nov 2005 10:47:55 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id jA4ElwI1013381; Fri, 4 Nov 2005 09:47:58 -0500 (EST) To: Jason Turner Cc: pgsql-sql@postgresql.org Subject: Re: Changing location of ORDER BY has large effect on performance, but not results... In-reply-to: <58e14cf00510281430y172deecak32839c101608522d@mail.gmail.com> References: <58e14cf00510281430y172deecak32839c101608522d@mail.gmail.com> Comments: In-reply-to Jason Turner message dated "Fri, 28 Oct 2005 15:30:55 -0600" Date: Fri, 04 Nov 2005 09:47:58 -0500 Message-ID: <13380.1131115678@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.006 required=5 tests=[AWL=0.006] X-Spam-Score: 0.006 X-Spam-Level: X-Archive-Number: 200511/54 X-Sequence-Number: 23305 Jason Turner writes: > My initial guess is that it is not able to utilize the index on > foo.tracktitle to sort the result set after foo has been joined with > other tables. Well, of course not. It should be able to do it before, though, and I'm a bit surprised that you didn't get the same plan from both cases seeing that the planner knows the first one is cheaper. Can you provide a complete self-contained test case? I'm not interested in trying to reverse-engineer your table definitions ... regards, tom lane