Re: jsonb and nested hstore

From: Greg Stark <stark(at)mit(dot)edu>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: Peter Geoghegan <pg(at)heroku(dot)com>, Andrew Dunstan <andrew(at)dunslane(dot)net>, Oleg Bartunov <obartunov(at)gmail(dot)com>, Tomas Vondra <tv(at)fuzzy(dot)cz>, Pgsql Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: jsonb and nested hstore
Date: 2014-03-13 10:53:05
Message-ID: CAM-w4HPxbtyKyFOZfZb8r4s64EbaYjDiPTZ2cNFNDvB2RZCQhQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2014-03-13 11:00:58 Re: 9a57858f1103b89a5674f0d50c5fe1f756411df6
Previous Message Greg Stark 2014-03-13 09:21:49 Re: jsonb and nested hstore