Re: [PERFORM] Bad query plans for queries on partitioned table

2007-12-05 Thread Julian Mehnle
Gregory, thanks for all the insight! It is much appreciated. Julian. signature.asc Description: This is a digitally signed message part.

Re: [PERFORM] Bad query plans for queries on partitioned table

2007-12-05 Thread Gregory Stark
"Julian Mehnle" <[EMAIL PROTECTED]> writes: > Gregory Stark wrote: >> "Julian Mehnle" <[EMAIL PROTECTED]> writes: >> > I actually do have constraints on all the partitions, e.g. for week >> > 34: [...] >> > >> > Shouldn't this be enough to give the query planner a clue that it >> > only has to joi

Re: [PERFORM] Bad query plans for queries on partitioned table

2007-12-04 Thread Julian Mehnle
Gregory Stark wrote: > "Julian Mehnle" <[EMAIL PROTECTED]> writes: > > I actually do have constraints on all the partitions, e.g. for week > > 34: [...] > > > > 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 >

Re: [PERFORM] Bad query plans for queries on partitioned table

2007-12-04 Thread Gregory Stark
"Julian Mehnle" <[EMAIL PROTECTED]> 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

Re: [PERFORM] Bad query plans for queries on partitioned table

2007-12-04 Thread Julian Mehnle
Gregory Stark wrote: > There are a few things going on here. > > 1) The optimizer can't build a plan which ignores those partitions > because the statistics are just approximations. You could insert into > one of them at any time and the statistics won't update immediately. If > you have a partitio

Re: [PERFORM] Bad query plans for queries on partitioned table

2007-12-04 Thread Gregory Stark
"Julian Mehnle" <[EMAIL PROTECTED]> writes: > However, if I restrict the query to just the partitions that actually do > have data in them ... There are a few things going on here. 1) The optimizer can't build a plan which ignores those partitions because the statistics are just approximations.

Re: [PERFORM] Bad query plans for queries on partitioned table

2007-12-04 Thread Julian Mehnle
Julian Mehnle wrote: > I have a large database with e-mail meta-data (no bodies) for over 100 > million messages. I am running PostgreSQL 8.2.4 on a server with 2GB > of RAM (shared_buffers = 240MB, temp_buffers = 128MB, work_mem = 256MB, > maintenance_work_mem = 256MB). I have the data split in

[PERFORM] Bad query plans for queries on partitioned table

2007-12-04 Thread Julian Mehnle
Hi all, I have a large database with e-mail meta-data (no bodies) for over 100 million messages. I am running PostgreSQL 8.2.4 on a server with 2GB of RAM (shared_buffers = 240MB, temp_buffers = 128MB, work_mem = 256MB, maintenance_work_mem = 256MB). I have the data split in two separate tables,