queries with subquery constraints on partitioned tables not optimized?

From: "Davor J(dot)" <DavorJ(at)live(dot)com>
To: pgsql-performance(at)postgresql(dot)org
Subject: queries with subquery constraints on partitioned tables not optimized?
Date: 2010-02-02 09:48:08
Message-ID: hk8sd1$2b79$1@news.hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Let's say you have one partitioned table, "tbl_p", partitioned according to
the PK "p_pk". I have made something similar with triggers, basing myself on
the manual for making partitioned tables.
According to the manual, optimizer searches the CHECKs of the partitions to
determine which table(s) to use (if applicable).

So if one has CHECKs of kind "p_pk = some number", queries like "SELECT *
from tbl_p where p_pk = 1" will only be searched in the appropriate table.
One can check this with EXPLAIN. So far so good.

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.

Is this normal, or am I missing something?

Kind regards,
Davor

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Yeb Havinga 2010-02-02 10:06:00 Re: Slow query: table iteration (8.3)
Previous Message wyx6fox 2010-02-02 06:55:35 Sincere apology for my insults and hand-waving in these mails:the jokes for pg concurrency write performance