Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 08D76B5DBE1 for ; Tue, 25 Oct 2011 13:43:55 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 29875-04 for ; Tue, 25 Oct 2011 16:43:48 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.8.0-rc2 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mail.postgresql.org (Postfix) with ESMTP id CD06FB5DBF4 for ; Tue, 25 Oct 2011 13:43:47 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id p9PGhj6K024673; Tue, 25 Oct 2011 12:43:45 -0400 (EDT) To: Linos cc: pgsql-performance@postgresql.org Subject: Re: CTE vs Subquery In-reply-to: <4EA6E252.6030002@linos.es> References: <4EA6E252.6030002@linos.es> Comments: In-reply-to Linos message dated "Tue, 25 Oct 2011 18:22:42 +0200" Date: Tue, 25 Oct 2011 12:43:45 -0400 Message-ID: <24672.1319561025@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.404 tagged_above=-10 required=5 tests=BAYES_00=-1.9, RP_MATCHES_RCVD=-0.504 X-Spam-Level: X-Archive-Number: 201110/210 X-Sequence-Number: 45432 Linos writes: > i am having any problems with performance of queries that uses CTE, can the > join on a CTE use the index of the original table? CTEs act as optimization fences. This is a feature, not a bug. Use them when you want to isolate the evaluation of a subquery. regards, tom lane