Skip site navigation (1) Skip section navigation (2)

Re: hstore equality-index performance question

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Stefan Keller <sfkeller(at)gmail(dot)com>
Cc: Sergey Konoplev <gray(dot)ru(at)gmail(dot)com>, pgsql-general List <pgsql-general(at)postgresql(dot)org>
Subject: Re: hstore equality-index performance question
Date: 2010-03-30 15:43:53
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-general
Stefan Keller <sfkeller(at)gmail(dot)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'


			regards, tom lane

In response to

pgsql-general by date

Next:From: Andy ColsonDate: 2010-03-30 15:46:11
Subject: Re: User action accounting
Previous:From: Stefan KellerDate: 2010-03-30 15:27:17
Subject: Re: hstore equality-index performance question

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group