Re: GiST: PickSplit and multi-attr indexes - Mailing list pgsql-hackers

From Greg Stark
Subject Re: GiST: PickSplit and multi-attr indexes
Date
Msg-id 87r7mt7b1i.fsf@stark.xeocode.com
Whole thread Raw
In response to Re: GiST: PickSplit and multi-attr indexes  (Greg Stark <gsstark@mit.edu>)
Responses Re: GiST: PickSplit and multi-attr indexes  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
Greg Stark <gsstark@MIT.EDU> writes:

> I'm not sure that GiST indexes behave the same way as btree indexes for the
> multi-column case. 
> 
> In a btree index the second column is entirely subordinate to the first
> column. In a GiST index the data is multi-dimensional, and all dimensions are
> equally important.

In fact on further consideration I do have a proposal.

If you look at the GiST implementations for various index types you'll see
that many (all?) take the same approach for PickSplit. In fact they pretty
much all have the same code copy/pasted to handle it.

The approach they take is to have a function which calculates an abstract
"distance" between any two entries. There's an algorithm that they use to pick
the split based on this distance function.

If you abandoned "PickSplit" and instead exposed this distance function as the
external API then the behaviour for multi-column indexes is clear. You
calculate the distance along all the axes and calculate the diagonal distance.

I think abandoning PickSplit for the distance function might also mean you
don't need a separate function for Penalty either, but I'm not sure on that.

-- 
greg



pgsql-hackers by date:

Previous
From: Bruno Wolff III
Date:
Subject: Re: need help on writing an aggregate function
Next
From: Tom Lane
Date:
Subject: Re: Minor problem with Makefile.shlib