by StavrosK · 14y ago · 0 comments
What you can do right now though is use PL/V8 to query the JSON fields. Then you can use functional indexes to still being able to speed up queries. Yes. You could that before but now there's a guarantee that a field of type json contains just that, meaning that your application logic will get simpler.
Or the insertion/conversion routine can assert that the JSON object is a string:string mapping only.
Since hstore only handles string:string mapping, the choice is either to silently corrupt data by stringifying all values in the json->hstore encoding, or erroring out if the input data is anything other than string:string.
The latter would be what I'd prefer, and more in line with usual Postgres behavior.
Still, there's no reason why you couldn't write a function to index JSON however you like.
Having said that, hstore is perfect when storing simple key/values. It's been battle tested and used for years and has some powerful and native indexing possibilities.