2 ms·
The article is showing off the -> operator and then proceeds to talk about indexes and using them for querying. Unfortunately, -> can't take advantage of inde
by pilif 14y ago
The article is showing off the -> operator and then proceeds to talk about indexes and using them for querying. Unfortunately, -> can't take advantage of indexes.
You'd have to use the @> operator and compare a partial hash.
So instead of
SELECT * FROM comics WHERE properties -> 'story_arc' = 'Throne of Atlantis'
You'd use
SELECT * FROM comics WHERE properties @> 'story_arc=>Throne of Atlantis'::hstore
The first query will not use an index on properties, the second one will.
See the first paragraph of F.16.3 on http://www.postgresql.org/docs/9.2/static/hstore.html http://www.postgresql.org/docs/9.2/static/hstore.html