Company
Date Published
Author
Matvey Arye
Word count
744
Language
English
Hacker News points
None

Summary

The problem lies in the query planning process of Postgres, which takes a long time for tables with many partitions, leading to performance degradation even when not processing all chunks in hypertables. The culprit was found to be in the `get_relation_info()` function, which fetches table statistics and opens metadata files from heap data files for all chunks, resulting in unnecessary work if chunk exclusion is possible. An optimization has been made by moving chunk exclusion to before stats are fetched, reducing planning times significantly in tests with large datasets, even when only a few chunks were involved.