X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 850F1D1B50C for ; Fri, 14 Nov 2003 16:41:26 +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 18783-07 for ; Fri, 14 Nov 2003 12:40:55 -0400 (AST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id 58C84D1B535 for ; Fri, 14 Nov 2003 12:40:54 -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 hAEGeh19026649; Fri, 14 Nov 2003 11:40:43 -0500 (EST) To: Neil Conway Cc: Josh Berkus , Christopher Kings-Lynne , PostgreSQL Performance Subject: Re: Query question In-reply-to: <87llqjj5n0.fsf@mailbox.samurai.com> References: <3FB303E9.20903@familyhealth.com.au> <200311122120.28882.josh@agliodbs.com> <87llqjj5n0.fsf@mailbox.samurai.com> Comments: In-reply-to Neil Conway message dated "Fri, 14 Nov 2003 11:07:15 -0500" Date: Fri, 14 Nov 2003 11:40:42 -0500 Message-ID: <26648.1068828042@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200311/114 X-Sequence-Number: 4674 Neil Conway writes: > Interesting -- I wonder if it would be possible for the optimizer to > detect this and avoid the redundant inner sort ... (/me muses to > himself) I think the ability to generate two sort steps is a feature, not a bug. This has been often requested in connection with user-defined aggregates, where it's handy to be able to control the order of arrival of rows at the aggregation function. If the optimizer suppressed the inner sort then we'd lose that ability. regards, tom lane