News for hackers. Stuff that matters.
Re:A love affair with PostgreSQL by pilif on Wednesday January 02, 2013 @05:47AM (#4996105)
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

There are no comments on this comment yet.