Postgres Planner Quirks: How to fix bad JSONB selectivity estimates

Опубликовано: 22 Март 2026
на канале: pganalyze
555
25

Find the article on our blog here:
https://pganalyze.com/blog/5mins-post...

In E115 of "5mins of Postgres" we discuss a common challenge when using equality and contains operators for querying JSONB columns, and why the Postgres planner will often get the estimates wrong for such queries, causing bad query plans.

Learn more about pganalyze:
https://pganalyze.com
https://pganalyze.com/newsletter
  / pganalyze  

Check out the pganalyze library for eBooks, webinars, and more:
https://pganalyze.com/resources

📑 What we have discussed in this episode of 5mins of Postgres:

PostgreSQL Stories: From slow query to fast—via stats - Blog post by Eric Fritz on the Render blog
https://render.com/blog/postgresql-sl...

Pitfalls of JSONB indexes in PostgreSQL - Blog post by Vsevolod Solovyov
https://vsevolod.net/postgresql-jsonb...

PostgreSQL: JSONB and Statistics - Blog post by Adrien Nayrat
https://blog.anayrat.info/en/2017/11/...

Less-silly selectivity for JSONB matching operators - Mailinglist thread on pgsql-hackers by Tom Lane
https://www.postgresql.org/message-id...

Improve selectivity estimation for assorted match-style operators - Postgres 13 commit by Tom Lane
https://git.postgresql.org/gitweb/?p=...

Extended statistics on expressions - Postgres 14 commit by Tomas Vondra
https://git.postgresql.org/gitweb/?p=...