aggregate planning with partitions - Mailing list pgsql-general

From Jonathan Ellis
Subject aggregate planning with partitions
Date
Msg-id e06563880703050825m194267dak43c58d6c104453e8@mail.gmail.com
Whole thread Raw
List pgsql-general
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

pgsql-general by date:

Previous
From: "Nik"
Date:
Subject: No buffer space available
Next
From: "Dustin Withers"
Date:
Subject: Bulk insert new and update out of temp table