4 ms·
Have you compared with postgresql's jsonb?
by TomMarius 6y ago
Have you compared with postgresql's jsonb?
- Beefin 6y agojsonb is limited in it's querying capabilities. you're essentially casting the json as a string when storing and querying, it's not truly json. therein lies the advantage of document model, native secondary indexes, $<queries> for everry nested layer, etc.
- indigo945 6y agoPostgres's jsonb format is definitely not "essentially" a string. You can get native indexes on json fields in Postgres, and you can query fields however you like.
- Beefin 6y agohttps://www.postgresql.org/docs/9.5/functions-json.html https://www.postgresql.org/docs/9.5/functions-json.html they are surrounded by quotes, is that not a string ?
- indigo945 6y agoIf a man is surrounded by trees, does he become a grove?
- fabian2k 6y agoThose are json literals in the SQL query. That has nothing at all to do with how json is stored in jsonb columns in the database itself.
- gnulinux 6y agoThis is among the most shallow comment I ever saw on HN. Just because `TreeSet a = [1,2,3]` is surrounded by [ and ] does that mean `a` is a list? When you do `jsonb j = '{"a":"c"}` postgres builds a separate data structure for you from that json, which allows you to use a btree index.
- Beefin 6y agoSELECT jdoc->'guid', jdoc->'name' FROM api WHERE jdoc @> '{"tags": ["qui"]}'; vs db.api.find({tags:"qui"}, {guid:1, name:1})
- takeda 6y agoNot sure what you are trying to show here, but only SQL statement helped me to understand that {guid: 1, name: 1} is to show these fields.
- fabian2k 6y agoI don't believe that is true, as far as I understand jsonb is a binary representation, not text. And there are certainly ways to index jsonb columns, either a function index on a particular jsonb expression or a GIN index so that you can perform contains (@>) queries against the whole jsonb contents.