Build extended stats on coordinators during ANALYZE
authorTomas Vondra <[email protected]>
Thu, 13 Jul 2017 16:22:30 +0000 (18:22 +0200)
committerTomas Vondra <[email protected]>
Thu, 13 Jul 2017 16:35:06 +0000 (18:35 +0200)
commit6d4a2588c8b2d548321d24177381b3520c4deee3
tree8dcdfc0fadb6a9eae9578bf8408ee8bcc8d5bf55
parent03162cb93078de77532bf08498d96345fe14ea68
Build extended stats on coordinators during ANALYZE

When running ANALYZE on a coordinator, we simply fetch the statistics
built on datanodes, and keep stats from a random datanode (assuming all
datanodes are similar in terms of data volume and data distribution).

This was only done for regular per-attribute stats, though, not for the
extended statistics added in PostgreSQL 10, causing various failures in
stats_ext tests due to missing statistics. This commit fixes this gap
by using the same approach as for simple statistics - we collect stats
from datanodes and keep the first result we receive for each statistic.

While working on this I realized this approach has some inherent issues,
particularly on columns that are distribution keys. As we keep stats
from a random node, we completely ignore MCV and histograms from the
remaining nodes. That may cause planning issues, but addressing it is
out of scope for this commit.
src/backend/commands/analyze.c
src/test/regress/expected/stats_ext.out