Hacker News new | comments | ask | show | jobs | submit login

Can I index fields within a JSON document in PostreSQL? Can I query them?

I.e. can I do something like SELECT json_field FROM data WHERE json_field.age > 15 ?




That query would be this:

SELECT json_field FROM data WHERE json_field->'age' > 15

Part of the performance increase for hstore is improvements for GIN indexes, and according to the author can be applied to json. So yes you can use indexes on your hstore or json documents.


Yes, this is what index scan performance metrics is about — PostgreSQL outperforms MongoDB here.



Yes, for a project I'm working on, I had a JSON array of objects that each had a key called name.

I have fast indexed queries that return any rows that have an object with a given name in it, and for full text search on that name along with a few other things.





Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact

Search: