Re: Asssociative Arrays: Best practices / snippets?

Поиск
Список
Период
Сортировка
От Steve Atkins
Тема Re: Asssociative Arrays: Best practices / snippets?
Дата
Msg-id EE7F465B-04BA-4589-84E8-2810B7F36871@blighty.com
обсуждение исходный текст
Ответ на Asssociative Arrays: Best practices / snippets?  (Stefan Keller <sfkeller@gmail.com>)
Ответы Re: Asssociative Arrays: Best practices / snippets?  (Stefan Keller <sfkeller@gmail.com>)
Список pgsql-general
On May 23, 2009, at 2:25 AM, Stefan Keller wrote:

> I have a use case where the I want to put an unforeseable number of
> key/value pairs in a column.
> Now, PostgreSQL has arrays as first class types.
> Are there any best practices and snippets (preferrably in plpgsql)
> for handling key/value pairs?

Take a look at "hstore". It's a data type in contrib that's intended
to store a set of key, value
pairs in a single column.

It's well suited for the case where you're not searching on the keys
and values. If you do
need to search on them then you can either index the hstore field with
a gin or gist index,
or use a separate EAV table for the keys and values.

Cheers,
   Steve


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

Предыдущее
От: Ludwig Kniprath
Дата:
Сообщение: Re: 8.3: timestamp subtraction
Следующее
От: Ivan Sergio Borgonovo
Дата:
Сообщение: psql Windows and variables