How to generate Postgres stats for Clickhouse foreign tables?
Opened this issue · 0 comments
george24601 commented
Hi,
My query joins Postgres tables with one Clickhouse foreign table, and the query plan is not efficient. For example, when my join selects an empty date range on the CH table, e.g. (event_date > 2025-01-01 and event_date < 2024-01-01), Postgres still foreign scans CH thousands of times.
I think the bad query plan is partially caused by the lack of stats, i.e., pg_stats
is empty for that Clickhouse foreign table, but no stats is generated after I run ANALYZE
on that Clickhouse foreign table.
My questions
- Did anyone experience a similar problem? How did you solve it?
- Should the Clickhouse FDW support the
fetch_size
anduse_remote_estimate
options, similar to the options in postgres_fdw?
Thanks,
George