Re: hstore equality-index performance question - Mailing list pgsql-general

From Tom Lane
Subject Re: hstore equality-index performance question
Date
Msg-id 24160.1269963833@sss.pgh.pa.us
Whole thread Raw
In response to Re: hstore equality-index performance question  (Stefan Keller <sfkeller@gmail.com>)
List pgsql-general
Stefan Keller <sfkeller@gmail.com> 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

pgsql-general by date:

Previous
From: Stefan Keller
Date:
Subject: Re: hstore equality-index performance question
Next
From: Andy Colson
Date:
Subject: Re: User action accounting