Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id AA05B634E22 for ; Tue, 2 Feb 2010 20:14:27 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 72364-03 for ; Wed, 3 Feb 2010 00:14:16 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mail.postgresql.org (Postfix) with ESMTP id D915C634E0B for ; Tue, 2 Feb 2010 20:14:16 -0400 (AST) 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 o130EEwD005003; Tue, 2 Feb 2010 19:14:14 -0500 (EST) To: "Davor J." cc: pgsql-performance@postgresql.org Subject: Re: queries with subquery constraints on partitioned tables not optimized? In-reply-to: References: Comments: In-reply-to "Davor J." message dated "Tue, 02 Feb 2010 10:48:08 +0100" Date: Tue, 02 Feb 2010 19:14:14 -0500 Message-ID: <5002.1265156054@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.443 tagged_above=-10 required=5 tests=BAYES_00=-2.599, SUBJECT_FUZZY_TION=0.156 X-Spam-Level: X-Archive-Number: 201002/44 X-Sequence-Number: 37465 "Davor J." writes: > Now, if one takes a subquery for "1", the optimizer evaluates it first > (let's say to "1"), but then searches for it (sequentially) in every > partition, which, for large partitions, can be very time-consuming and goes > beyond the point of partitioning. No, the optimizer doesn't "evaluate it first". Subqueries aren't ever assumed to reduce to constants. (If you actually do have a constant expression, why don't you just leave out the word SELECT?) regards, tom lane