Re: [PERFORM] working around JSONB's lack of stats?

2015-01-28 Thread Tomas Vondra
On 29.1.2015 00:03, Josh Berkus wrote: > On 01/28/2015 11:48 AM, Tomas Vondra wrote: >> 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_dist

Re: [PERFORM] working around JSONB's lack of stats?

2015-01-28 Thread Peter Geoghegan
On Wed, Jan 28, 2015 at 3:42 PM, Josh Berkus wrote: > jsonb_col @> '[ "key1" ]' > or jsonb_col ? 'key1' > if in MCE, assign % from MCE > otherwise assign 1% of non-MCE % > > jsonb_col @> '{ "key1": "value1" }' > if in MCE, assign MCE% * 0.1 > otherwise assign 0.01 o

Re: [PERFORM] working around JSONB's lack of stats?

2015-01-28 Thread Josh Berkus
On 01/28/2015 03:34 PM, Peter Geoghegan wrote: > On Wed, Jan 28, 2015 at 3:03 PM, Josh Berkus wrote: >> We already have most_common_elem (MCE) for arrays and tsearch. What if >> we put JSONB's most common top-level keys (or array elements, depending) >> in the MCE array? Then we could still appl

Re: [PERFORM] working around JSONB's lack of stats?

2015-01-28 Thread Peter Geoghegan
On Wed, Jan 28, 2015 at 3:03 PM, Josh Berkus wrote: > We already have most_common_elem (MCE) for arrays and tsearch. What if > we put JSONB's most common top-level keys (or array elements, depending) > in the MCE array? Then we could still apply a simple rule for any path > criteria below the to

Re: [PERFORM] working around JSONB's lack of stats?

2015-01-28 Thread Josh Berkus
On 01/28/2015 11:48 AM, Tomas Vondra wrote: > 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

Re: [PERFORM] working around JSONB's lack of stats?

2015-01-28 Thread Tomas Vondra
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