5 ms·
That would be one way, or On Postgres, you could use arrays: http://www.postgresql.org/docs/9.3/static/arrays.html http://www.postgresql.org/docs/9.3/static/a
by sendob 13y ago
That would be one way, or
On Postgres, you could use arrays:
http://www.postgresql.org/docs/9.3/static/arrays.html http://www.postgresql.org/docs/9.3/static/arrays.html
also has some great contrib modules as well like: http://www.postgresql.org/docs/9.3/static/intarray.html http://www.postgresql.org/docs/9.3/static/intarray.html
Mongodb documents their multikey indexes for a similar approach:
http://docs.mongodb.org/manual/core/index-multikey/ http://docs.mongodb.org/manual/core/index-multikey/
not to take away from rethinkdb, awesome to see a project move rapidly!
- petergeoghegan 13y agoImportantly, in Postgres the arrays are indexable with a GIN (inverted) index. So you can ask arbitrary questions along the lines of: show me all rows in this table that have any of the following integers: [5, 7, 9] somewhere in their array column. This will be performed very efficiently. In recent versions, Postgres will even keep track of statistics for arrays (and other, similar non-scalar types), so that you can get a good selectivity estimate, which is often critical to getting a good plan from the query planner.