Re: jsonpath

From: "Jonathan S(dot) Katz" <jkatz(at)postgresql(dot)org>
To: Alexander Korotkov <a(dot)korotkov(at)postgrespro(dot)ru>
Cc: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, Nikita Glukhov <n(dot)gluhov(at)postgrespro(dot)ru>, Tomas Vondra <tomas(dot)vondra(at)2ndquadrant(dot)com>, Andres Freund <andres(at)anarazel(dot)de>, Oleg Bartunov <obartunov(at)postgrespro(dot)ru>, Michael Paquier <michael(at)paquier(dot)xyz>, Stas Kelvich <s(dot)kelvich(at)postgrespro(dot)ru>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, Thomas Munro <thomas(dot)munro(at)enterprisedb(dot)com>, David Steele <david(at)pgmasters(dot)net>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Andrew Dunstan <andrew(dot)dunstan(at)2ndquadrant(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>
Subject: Re: jsonpath
Date: 2019-03-17 18:29:44
Message-ID: 36067d03-c085-b3ef-f379-a00aa4bff7e5@postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 3/17/19 1:14 PM, Alexander Korotkov wrote:
> On Sun, Mar 17, 2019 at 8:06 PM Jonathan S. Katz <jkatz(at)postgresql(dot)org> wrote:
>> On 3/17/19 1:02 PM, Alexander Korotkov wrote:
>>>
>>> Thank you for the explanation. Is it jsonb_ops or jsonb_path_ops?
>>
>> I just used "USING gin(col)" so jsonb_ops.
>
> I see. So, jsonb_ops extracts from this query only existence of
> .length key. And I can bet it exists in all (or almost all) the
> documents. Thus, optimizer thinks index might be useful, while it's
> useless. There is not much can be done while we don't have statistics
> for jsonb (and access to it from GIN extract_query). So, for now we
> can just refuse from extracting only keys from jsonpath in jsonb_ops.
> But I think it would be better to just document this issue. In future
> we should improve that with statistics.

That seems to make sense, especially given how I've typically stored
JSON documents in PostgreSQL. It sounds like this particular problem
would be solved appropriately with JSONB statistics.

Thanks,

Jonathan

In response to

  • Re: jsonpath at 2019-03-17 17:14:24 from Alexander Korotkov

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2019-03-17 19:06:07 Re: Fix XML handling with DOCTYPE
Previous Message Chapman Flack 2019-03-17 18:13:03 Re: Fix XML handling with DOCTYPE