2

SP-GiST is an abbreviation for space-partitioned GiST in PostgreSQL 9.2.3. It can be used to find the similar tuple by creating the sp-gist index on the column.

e.g:

create index pt_spgist_idx on geo using spgist(point);

'Point' column on table 'Geo' is Point type of Geometric Types.

and we can use sql sentence to find the nearest point of (34.34898,-92.82934) with spgist index 'pt_spgist_idx':

select point from geo where point ~= '(34.34898,-92.82934)'

We can see that sp-gist index supports Geometric Point type.

The question is:

Does spgist extension in PostgreSQL 9.2.3 support float or int array? For I want to use sp-gist index in int array whose size is 500.

Evan Carroll
65.7k50 gold badges259 silver badges510 bronze badges
asked Mar 12, 2013 at 15:04

1 Answer 1

1

No, by default SP-GiST only supports these operators over point ranges box and text

Name Indexed Data Type Indexable Operators
kd_point_ops point << <@ <^ >> >^ ~=
quad_point_ops point << <@ <^ >> >^ ~=
range_ops any range type && &< &> -|- << <@ = >> @>
box_ops box << &< && &> >> ~= @> <@ &<| <<| |>> |&>
text_ops text < <= = > >= ~<=~ ~<~ ~>=~ ~>~

That's not to say that it can not work over float or int[] but it may be awkward unless they have any special internal designation you can exploit for partitioning. That is to say, if your int[] and array are likely to produce balanced trees, or are equally distributed there is no point whatsoever (afaik).

answered Feb 2, 2017 at 21:01
1
  • If arrays were guaranteed to have always the same number of dimensions, SP-Gist partitioning makes sense in a mathematical point of view. Your array would represent a point in an n-dimensional space. As an array, in principle, can have variable number of dimensions... this might be the reason why this isn't implemented. Commented Feb 2, 2017 at 23:39

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.