
Create Statistics in PostgreSQL 10 - samber
https://www.citusdata.com/blog/2018/03/06/postgres-planner-and-its-usage-of-statistics/
======
fabian2k
The biggest issue related to statistics I've encountered is when using jsonb
columns. As far as I understand they have a hardcoded statistic, which can
cause pretty bad plans if your data isn't close to that value. You can create
an index on individual keys in the jsonb column, which do have their own
statistic, but that is not really an option for most cases where you'd use
jsonb in the first place.

Bad statistics can really mess up queries, so any tool to fix this kind of
situation is very welcome. I don't think this specific tool would help with
this variant of bad statistics, unfortunately.

~~~
joevandyk
[https://blog.anayrat.info/en/2017/11/26/postgresql---
jsonb-a...](https://blog.anayrat.info/en/2017/11/26/postgresql---jsonb-and-
statistics/) explains this problem in more detail.

------
comboy
Will that slow down inserts? Or am I understanding it wrong and this is just
one time generation like vacuum analyze?

~~~
gaius
The latter. What would slow down inserts is excessive indexing

~~~
comboy
Yeah, been there. Kinda too bad that it's just a one time thing. But even if
it wouldn't be, I forgot that unlike index update it doesn't have to block
transaction, it can be updated whenever later and doesn't have to be done
after each insert.

Anyway, postgres team is doing awesome things. So much great functionality
while keeping it rock stable. Kudos.

~~~
gaius
I assume once you’ve told it once it will maintain them when it autovacuums.
But the correlations shouldn’t change that much if the source data is
genuinely connected

------
Tostino
Very cool feature which will help certain use cases which have no other way of
improving the plan chosen without changing the way the data is stored.

