With its newish hstore extension, Postgres now has the ability to store schemaless data, like MongoDB, Riak, and other newfangled data stores. I've been wanting to play with it for a while and recently started on something that I thought might benefit from it. Inside model A, I'm storing an arbitrary number of rows of model B, which will only ever be referenced by model A. To my understanding this is something that Mongo excels at, so I thought maybe hstore could help as well.
I found that it is in fact not appropriate for such an application.
First of all, its big pluses:
- No schema -- you can insert and select whatever key/value pairs you want at runtime.
- No worrying about serializing/deserializing -- it's natively an arbitrary hash.
- Indexes on the values -- you can query on the values of anything you stick in there.
But now, the limitations:
- An hstore column can only store a single hash, it doesn't store arbitrary JSON. So, no list of objects in an array.
- The values can only be text -- no numbers, no datetimes, no hashes.
So it seems hstore isn't well-suited for nested model relationships like Mongo is. But it does seem to be a powerful, simple way to store things like metadata.
Co-Founder and CTO of Medstro