Using GIN index to retrieve distinct values

Поиск
Список
Период
Сортировка
От Alexander Hill
Тема Using GIN index to retrieve distinct values
Дата
Msg-id CA+KBOKwJkG5_vMi3W6D9mXMbLJA_i4qrpPfa-Kg5EqLvBBMYow@mail.gmail.com
обсуждение исходный текст
Список pgsql-general
Hi all,

My understanding of a GIN index is that it maps each unique key to the set of items containing that key. That suggests to me that enumerating the distinct keys efficiently using the index should be possible in some cases. I understand that given the nature of the GIN framework, the original key won't always be able to be retrieved. But in certain cases like int array, for example, would it be possible?

While on the topic: what's the canonical way to do that kind of query?

CREATE TABLE tagged_items
(
    id serial PRIMARY KEY,
    tag_ids integer[]
);

select array_agg(tag_id)
from (select distinct unnest(tag_ids) from items) tag_id;

Thanks!
Alex

В списке pgsql-general по дате отправления:

Предыдущее
От: Virendra Kumar
Дата:
Сообщение: Re: how to slow down parts of Pg
Следующее
От: Laurenz Albe
Дата:
Сообщение: Re: how to slow down parts of Pg