Обсуждение: composite type array and index

Поиск
Список
Период
Сортировка

composite type array and index

От
Marek Lewczuk
Дата:
Hello everyone,
it's great to have in next release (8.3) great feature: composite type
array. I'm waiting to see how it works, however I wonder whether it will
be possible to create an index on a column of composite type array just
like we have an index on integer[] column (using gin or intarray module) ?

Regards,
Marek



Re: composite type array and index

От
"Merlin Moncure"
Дата:
On 5/24/07, Marek Lewczuk <newsy@lewczuk.com> wrote:
> Hello everyone,
> it's great to have in next release (8.3) great feature: composite type
> array. I'm waiting to see how it works, however I wonder whether it will
> be possible to create an index on a column of composite type array just
> like we have an index on integer[] column (using gin or intarray module) ?

good question.   one small point here.  you can index int[] with
standard btree and not gist which optimizes equality searches, etc.
The problem is not the array but that composite types have no defined
comparison function.

You can create an index on table with composite array type but it's
not really any use because the operator class is not defined for the
type.  Array orderings decompose to orderings on the internal type.
If you really need the functionality you can create an operator class
for btree (for simple operations) or gist (for more complex searches
inside the array), gin, etc.

I guess it would be kinda nice if composite types had a 'operator of
last resort' which would work as the sql-row comparison does, and do
ordering left to right for purposes of comparison.

merlin