Re: int2vector and btree indexes - Mailing list pgsql-hackers

From Amit Langote
Subject Re: int2vector and btree indexes
Date
Msg-id 4a14479b-0602-5f09-bd79-983069e7453f@lab.ntt.co.jp
Whole thread Raw
In response to int2vector and btree indexes  (Amit Langote <Langote_Amit_f8@lab.ntt.co.jp>)
Responses Re: int2vector and btree indexes  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
On 2016/10/11 15:58, Amit Langote wrote:
> If I create btree index on a int2vector column, it does not get used for
> queries because the query search always fails to match the index operator
> (family).
> 
> During index creation, GetDefaultOpClass() returns array_ops for a
> int2vector index column, because type int2vector is binary-coercible with
> anyarray (which is array_ops's input type).  Whereas queries involving
> int2vector columns would use a int2vector_ops operator.

I was wrong that the index *never* gets used.  It does in fact get used if
the operator is an ordering search operator (<, <=, >, >=), in which case
the query would use an array_ops operator (which is a btree operator class
for type anyarray) and hence matches the index operator family.  I failed
to mention in my original message that int2vector_ops is a hash operator
class.  There is exactly one =(int2vector, int2vector) operator in the
system of which there is no btree equivalent.

I guess there is not much to complaint about here after all.  Sorry about
the noise.

Thanks,
Amit





pgsql-hackers by date:

Previous
From: Torsten Zuehlsdorff
Date:
Subject: Re: kqueue
Next
From: Heikki Linnakangas
Date:
Subject: Re: memory leak in e94568ecc10 (pre-reading in external sort)