Re: queries with subquery constraints on partitioned tables not optimized?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





On Tue, Feb 2, 2010 at 7:14 PM, Tom Lane <tgl@xxxxxxxxxxxxx> wrote:
"Davor J." <DavorJ@xxxxxxxx> 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

[Postgresql General]     [Postgresql PHP]     [PHP Users]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Yosemite]

  Powered by Linux