Search Postgresql Archives

aggregate planning with partitions

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

 



I have a table, "connection_events", partitioned via inheritance on a
column "logtime."  I'm running 8.2.  Mostly the partitioning works
pretty well.  I have noticed though that the query

select max(logtime) from connection_events

always uses seq_scan across all partitions, which is painful.
(Rephrasing it as a limit query does not change the plan.)

I've run analyze, and pg can tell that in a single partition using the
logtime index is the right thing to do, but it can't when the main
table is queried.

I can write a function to force index use by querying each partition
separately but I wanted to know if (a) there is a simpler solution I'm
missing and (b) if there is a generalizable principle here that can
help me avoid problems with the planner in the future.  (From my
single data point I would guess "avoid aggregates" but that may be
oversimplified.)

Thanks,

-Jonathan


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux