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