Partitioned queries
Now that the data is in the partitions, it's a good idea to update statistics. It's also important to confirm that the constraint_exclusion
feature is active:
ANALYZE; SHOW constraint_exclusion; constraint_exclusion ---------------------- partition
Constraint exclusion allows the query planner to avoid including partitions in a query when it can prove they can't provide useful rows to satisfy it. In PostgreSQL 8.4 and later, the default value of partition
turns this on, when partitioned tables are referenced, and off otherwise. In earlier versions, it defaults to off
. You will have to turn the parameter on, once you start using partitions in earlier versions if you expect them to work properly.
Queries against the whole table execute the same as before the rows were relocated, except now the statistics are good for everything except the parent table:
EXPLAIN ANALYZE SELECT * FROM orders; QUERY PLAN ---------- Result (cost=0.00..1292.00 rows...