From: Nikolas Everett <nik9000@gmail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Davor J. <DavorJ@live.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: queries with subquery constraints on partitioned tables not optimized?
Date: Wed, 3 Feb 2010 10:54:13 -0500
Message-ID: <d4e11e981002030754id1e3b2em7fa3e7a7ac0daef3@mail.gmail.com> (raw)
In-Reply-To: <5002.1265156054@sss.pgh.pa.us>
References: <hk8sd1$2b79$1@news.hub.org>
<5002.1265156054@sss.pgh.pa.us>
On Tue, Feb 2, 2010 at 7:14 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> "Davor J." <DavorJ@live.com> 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
If you don't have a constant expression then you can either explicitly loop
in the calling code or a function or you could index the key in all the
subtables. The index isn't really optimal but it gets the job done.
Nik
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-performance@postgresql.org
Cc: nik9000@gmail.com, tgl@sss.pgh.pa.us, DavorJ@live.com
Subject: Re: queries with subquery constraints on partitioned tables not optimized?
In-Reply-To: <d4e11e981002030754id1e3b2em7fa3e7a7ac0daef3@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox