Re: jsonb and nested hstore - Mailing list pgsql-hackers

From Greg Stark
Subject Re: jsonb and nested hstore
Date
Msg-id CAM-w4HPxbtyKyFOZfZb8r4s64EbaYjDiPTZ2cNFNDvB2RZCQhQ@mail.gmail.com
Whole thread Raw
In response to Re: jsonb and nested hstore  (Greg Stark <stark@mit.edu>)
Responses Re: jsonb and nested hstore  (Andrew Dunstan <andrew@dunslane.net>)
List pgsql-hackers
Fwiw I have a few questions -- but beware, I'm a complete neophyte
when it comes to jsonb style document databases so these are more
likely to represent misconceptions on my part than problems with
jsonb.

I naively though a gin index on a jsonb would help with queries like
WHERE col->'prop' = 'val'. In fact it only seems to help with WHERE
col ? 'prop'. To help with the former it looks like I need an
expression index on col->'prop'  is that right? There doesn't seem to
be an operator that combines both a dereference and value test into a
single operator so I don't think our index machinery can deal with
this. Or am I supposed to use contains and construct a json object for
the test?

I also find it awkward that col->>'prop' returns the json
representation of the property. If it's text that means it's
double-quoted. I would think that a user storing text in a json
property would want a way to pull out the text that json property
represents so he doesn't have to write col->>'prop' = '"foo"' and
doesn't need to strip the quotes (and de-escape the string?) before
displaying the value or passing it through other apis.



pgsql-hackers by date:

Previous
From: Greg Stark
Date:
Subject: Re: jsonb and nested hstore
Next
From: Andres Freund
Date:
Subject: Re: 9a57858f1103b89a5674f0d50c5fe1f756411df6