I'm playing around with postgresql 9.3's hstore. I'm trying to use and index for an hstore column just like documentation states. MY problem is that the index appear not to be used. Let me give you an example:
I created a table 'Person':
=# CREATE TABLE Person (Id BIGSERIAL PRIMARY KEY NOT NULL, Values hstore);
And inserted a test value:
=# INSERT INTO Person (Values, 'a=>1,b=>3');
Then if I EXPLAIN a SELECT query which uses operator "@>" on 'Values' column, I unsurprisingly get:
=# EXPLAIN SELECT P.* FROM Person AS P WHERE P.Values @> hstore('a', '1');
QUERY PLAN
----------------------------------------------------------
Seq Scan on person p (cost=0.00..24.50 rows=1 width=40)
Filter: ("values" @> '"a"=>"1"'::hstore)
No index < - > sequential scan. Makes sense. Anyway, it doesn't matter if I create a GIN or GIST index, the explain keeps talking about sequential scan:
=# CREATE INDEX IX_GIN_VALUES ON Person USING GIN (values);
CREATE INDEX
=# EXPLAIN SELECT P.* FROM Person P WHERE P.values @> hstore('a', '1');
QUERY PLAN
----------------------------------------------------------
Seq Scan on person p (cost=0.00..1.01 rows=1 width=246)
Filter: ("values" @> '"age"=>"2"'::hstore)
Maybe I'm missing something obvious?