Cost-based optimizer statistics

To give cost-based optimizer an idea of table’s cardinality it is recommended to issue queries like this:

CREATE STATISTICS offers_stats ON id FROM offers;

Documentation states that “The cost-based optimizer will not support automated use of statistics during this time period.” Does it mean that I need to periodically issue create statistics statements to update statistics?

I’m asking because if I issue create statistics … queries BEFORE I load my data, optimizer will not use statistics after data is loaded. As the result some joins are very slow.

Yes your understanding is correct: the statistics are not currently updated automatically. You need to issue CREATE STATISTICS after the data is loaded, not before.

Good question!

Ok, that’s not a problem. But, please, express this limitation more clearly in docs. It seems that optimizer statistics is not documented at all.

Thank you!

I’ve filed an issue with our Docs team to update accordingly. Thank you for your feedback!