X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 1979C5675E for ; Wed, 16 Mar 2005 15:42:01 +0000 (GMT) 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 19844-10 for ; Wed, 16 Mar 2005 15:41:53 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id CA13B5674C for ; Wed, 16 Mar 2005 15:41:52 +0000 (GMT) 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 j2GFfqtD006304; Wed, 16 Mar 2005 10:41:52 -0500 (EST) To: "Tambet Matiisen" Cc: ch@rodos.fzk.de, pgsql-sql@postgresql.org Subject: Re: How to force subquery scan? In-reply-to: References: Comments: In-reply-to "Tambet Matiisen" message dated "Wed, 16 Mar 2005 16:52:50 +0200" Date: Wed, 16 Mar 2005 10:41:52 -0500 Message-ID: <6303.1110987712@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200503/230 X-Sequence-Number: 20709 "Tambet Matiisen" writes: > It seems that subquery scan is only used, when the query can not be > translated into single flat query. Which is mostly good, I assume. The planner thinks so anyway ;-) If you're desperate you can put in an optimization fence, for instance LIMIT or OFFSET. SELECT * FROM (SELECT ... OFFSET 0) ss; In principle the planner could figure out that this offset is a no-op, throw it away, and then flatten the query. But it doesn't at the moment, and I doubt we'll teach it to do so in the future. regards, tom lane