Skip site navigation (1) Skip section navigation (2)

Re: Bad query plans for queries on partitioned table

From: Gregory Stark <stark(at)enterprisedb(dot)com>
To: "Julian Mehnle" <julian(at)mehnle(dot)net>
Cc: <pgsql-performance(at)postgresql(dot)org>
Subject: Re: Bad query plans for queries on partitioned table
Date: 2007-12-05 00:39:45
Message-ID: 8763ze6kku.fsf@oxford.xeocode.com (view raw or flat)
Thread:
Lists: pgsql-performance
"Julian Mehnle" <julian(at)mehnle(dot)net> writes:

> I actually do have constraints on all the partitions, e.g. for week 34:
>
>   Check constraints [for email_2007_week34]:
>     "email_2007_week34_ts_check" CHECK (ts >= '2007-08-20 00:00:00'::timestamp without time zone AND ts < '2007-08-27 00:00:00'::timestamp without time zone)
>
>   Check constraints [for email_2007_week34_extras]:
>     "email_2007_week34_extras_ts_check" CHECK (ts >= '2007-08-20 00:00:00'::timestamp without time zone AND ts < '2007-08-27 00:00:00'::timestamp without time zone)
>
> Shouldn't this be enough to give the query planner a clue that it only
> has to join the "email" and "email_extras" tables' partitions pair-wise,
> as opposed to cross-joining them?

Ah, well, this falls under "The optimizer is a bit dumb about partitioned
tables". It only looks at the constraints to compare against your WHERE
clause. It doesn't compare them against the constraints for other tables to
see if they're partitioned on the same key and therefore can be joined
table-by-table.

I want 8.4 to be cleverer in this area but there's a ton of things it has to
learn.

-- 
  Gregory Stark
  EnterpriseDB          http://www.enterprisedb.com
  Get trained by Bruce Momjian - ask me about EnterpriseDB's PostgreSQL training!

In response to

Responses

pgsql-performance by date

Next:From: Mark MielkeDate: 2007-12-05 00:55:03
Subject: Re: RAID arrays and performance
Previous:From: James MansionDate: 2007-12-04 23:58:31
Subject: Re: RAID arrays and performance

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group