X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id D83E4D70BC for ; Fri, 2 Sep 2005 11:41:02 -0300 (ADT) 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 89356-05 for ; Fri, 2 Sep 2005 14:41:01 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id DC78CD70A7 for ; Fri, 2 Sep 2005 11:41:00 -0300 (ADT) 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 j82EesXI014075; Fri, 2 Sep 2005 10:40:54 -0400 (EDT) To: Matteo Beccati Cc: Simon Riggs , pgsql-performance@postgresql.org Subject: Re: ORDER BY and LIMIT not propagated on inherited In-reply-to: <43184B8F.2090505@beccati.com> References: <43182789.4070307@beccati.com> <1125664532.3956.278.camel@localhost.localdomain> <43184B8F.2090505@beccati.com> Comments: In-reply-to Matteo Beccati message dated "Fri, 02 Sep 2005 14:54:39 +0200" Date: Fri, 02 Sep 2005 10:40:54 -0400 Message-ID: <14074.1125672054@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] X-Spam-Level: X-Archive-Number: 200509/54 X-Sequence-Number: 14362 Matteo Beccati writes: > The correct strategy IMHO would > be applying the order by and limit for each child table (which results > in an index scan, if possible), appending, then finally sorting a bunch > of rows, and limiting again. This would be a win in some cases, and in many others a loss (ie, wasted sort steps). The hard part is determining when to apply it. regards, tom lane