4 ms·
Wow, hstore really isn't a great alternative to an actual document DB. The "better" Postgres option would be a JSON type and functional indexes.
by mrkurt 14y ago
Wow, hstore really isn't a great alternative to an actual document DB. The "better" Postgres option would be a JSON type and functional indexes.
- shawn-butler 14y agoThere is a JSON type but it just validates content. HSTORE can be fully indexed (gIST and GIN). Just have to roll your own object graphs for nesting if that's what you need to do. I swear I have typed this exact same comment previously. Deja vu, maybe
- mrkurt 14y agoJSON type gives you some typed values within the doc, multi-level nesting, etc. You can add functional indexes (http://www.postgresql.org/docs/9.1/static/indexes-expressional.html http://www.postgresql.org/docs/9.1/static/indexes-expression...) to index specific attributes within the JSON, do legit sorts over values, reasonable array queries, etc. It seems much, much closer to what Mongo does than anything you can do with hstore.
- shawn-butler 14y agoI think you just restated my comment. Do you believe expression indexes do not apply to HSTORE? I consider both HSTORE (key/value) and the current JSON type and record functions are just intermediate steps to a fuller API [0]. [0]: http://www.postgresql.org/message-id/50EC971C.3040003@dunslane.net http://www.postgresql.org/message-id/50EC971C.3040003@dunsla...
- aaronblohowiak 14y agohttp://news.ycombinator.com/item?id=4764834 http://news.ycombinator.com/item?id=4764834
- deleted 14y ago[deleted]
- vog 14y ago> JSON type and functional indexes Those "Indexes on Expressions" are really a great feature that can also be combined with XML (not just JSON) and any other types. I recommend everyone to have a look at those: http://www.postgresql.org/docs/9.2/static/indexes-expressional.html http://www.postgresql.org/docs/9.2/static/indexes-expression...
- arethuza 14y agoIs there any way in those expressions to parse JSON and perform arbitrary calculations - i.e. like CouchDB views?
- zurn 14y agoSure, you can write server side procedures in f.ex. javascript that do arbitrary things with the json.
- vog 14y agoTo be fair, one should note that "only" the languages C, Python, Perl and Tcl [1] are officially supported by PostgreSQL. Also, there are 3rd-party bindings for other languages such as Java, PHP, R, Ruby, Scheme, sh: http://www.postgresql.org/docs/9.2/interactive/external-pl.html http://www.postgresql.org/docs/9.2/interactive/external-pl.h... However, the PostgreSQL documentation doesn't mention JavaScript support anywhere. Are you sure there exists mature PL/JavaScript binding for PostgreSQL? If so, their docs should be updated. [1] There's also "pgSQL", but that's a special-purpose language you won't find outside the database world. I don't recommend learning it unless you have strange requirements that make PL/pgSQL a perfect fit. For normale usage, use PL/Python or PL/Perl. In simple cases, use SQL directly.
- zurn 14y agoYes, #1 hit when you Google for postgresql JavaScript: https://code.google.com/p/plv8js/ https://code.google.com/p/plv8js/ I can't vouch for any particular maturity level but seems to have active users and it's been around a few years already.