Re: GiST penalty functions [PoC]

From: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
To: amborodin(at)acm(dot)org
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, Alexander Korotkov <a(dot)korotkov(at)postgrespro(dot)ru>, Михаил Бахтерев <mike(dot)bakhterev(at)gmail(dot)com>
Subject: Re: GiST penalty functions [PoC]
Date: 2016-09-07 21:31:39
Message-ID: 753b8caf-ebe1-fa58-dfa3-ac5b74fb7f2e@iki.fi
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 09/07/2016 09:20 PM, Andrew Borodin wrote:
> Well, arithmetics is too fragile.
>
> This version of float packing with arithmetical packaging
> static float
> pack_float(float actualValue, int realm)
> {
> double max,min;
> max = FLT_MAX / ( 8 >> realm );
> min = FLT_MAX / ( 16 >> realm );
> if( realm == 0 )
> min = 0;
> /* squeeze the actual value between min and max */
> return ( min + (actualValue * ( max - min ) / FLT_MAX));
> }
> Inserts are the same as of bithacked pack_float, but selects are 5 times slower.
> When we are trying to pack value linearly into range we loose too much bits.

That's why I suggested scaling it by the new value's volume and/or
edge-sum. I was hoping that the old and new values are roughly of the
same magnitude, so that it would work out. I guess not.

But we could probably something like the above too, if we use
logarithmic or exponential, rather than linear, packing. Something like:

static float
pack_float(float actualValue, int realm)
{
double val;

val = sqrt(sqrt(actualValue));

if (realm == 0)
return actualvalue;
if (realm == 1)
return actualValue * sqrt(sqrt(FLT_MAX));
if (realm == 2)
return actualValue * sqrt(FLT_MAX);
}

Unfortunately, sqrt(x) isn't very cheap.

- Heikki

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Heikki Linnakangas 2016-09-07 21:36:18 Re: Parallel tuplesort (for parallel B-Tree index creation)
Previous Message Peter Geoghegan 2016-09-07 21:27:23 Re: Is tuplesort_heap_siftup() a misnomer?