Re: working around JSONB's lack of stats? - Mailing list pgsql-performance

From Tomas Vondra
Subject Re: working around JSONB's lack of stats?
Date
Msg-id 54C93CF2.3020600@2ndquadrant.com
Whole thread Raw
In response to working around JSONB's lack of stats?  (Josh Berkus <josh@agliodbs.com>)
List pgsql-performance
On 27.1.2015 08:06, Josh Berkus wrote:
> Folks,
>
...
>
> On a normal column, I'd raise n_distinct to reflect the higher
> selecivity of the search terms.  However, since @> uses contsel,
> n_distinct is ignored.  Anyone know a clever workaround I don't
> currently see?

I don't see any reasonable workaround :-(

ISTM we'll have to invent a way to collect useful stats about contents
of JSON/JSONB documents. JSONB is cool, but at the moment we're mostly
relying on defaults that may be reasonable, but still misfire in many
cases. Do we have any ideas of how that might work?

We're already collecting stats about contents of arrays, and maybe we
could do something similar for JSONB? The nested nature of JSON makes
that rather incompatible with the flat MCV/histogram stats, though.

regards
--
Tomas Vondra                http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services


pgsql-performance by date:

Previous
From: Merlin Moncure
Date:
Subject: Re: Why is PostgreSQL not using my index?
Next
From: Josh Berkus
Date:
Subject: Re: working around JSONB's lack of stats?