Stefan Keller <sfkeller@xxxxxxxxx> writes: > I'm trying to optimize the latter query: > # SELECT id, (kvp->'a') FROM mytable WHERE kvp ? 'a'; The hstore gist and gin opclasses contain support for that. > ...or something like this (which also involves the '->' operator) > # SELECT id FROM mytable WHERE (kvp->'a') = 'x'; You could transform this into a gist/gin indexable query kvp @> ('a' => 'x') although I think the actually indexed part of it is just the search for rows that contain key 'a', so it's not really any better than kvp ? 'a' AND (kvp->'a') = 'x' performance-wise. regards, tom lane -- Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general