Re: WIP: BRIN multi-range indexes

From: Tomas Vondra <tomas(dot)vondra(at)2ndquadrant(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Andres Freund <andres(at)anarazel(dot)de>
Cc: Mark Dilger <hornschnorter(at)gmail(dot)com>, Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: WIP: BRIN multi-range indexes
Date: 2018-03-21 00:07:22
Message-ID: 9b7551f2-93fb-3708-2705-35c42f0e6734@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 03/04/2018 01:14 AM, Tomas Vondra wrote:
> ...
>
> The one overflow issue I found in the patch is that the numeric
> "distance" function does this:
>
> d = DirectFunctionCall2(numeric_sub, a2, a1); /* a2 - a1 */
>
> PG_RETURN_FLOAT8(DirectFunctionCall1(numeric_float8, d));
>
> which can overflow, of course. But that is not fatal - the index may get
> inefficient due to non-optimal merging of ranges, but it will still
> return correct results. But I think this can be easily improved by
> passing not only the two values, but also minimum and maximum, and use
> that to normalize the values to [0,1].
>

Attached is an updated patch series, addressing this possible overflow
the way I proposed - by computing (a2 - a1) / (b2 - b1), which is
guaranteed to produce a value between 0 and 1.

The two new arguments are ignored for most "distance" functions, because
those can't overflow or underflow in double precision AFAICS.

regards

--
Tomas Vondra http://www.2ndQuadrant.com
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

Attachment Content-Type Size
0001-Pass-all-keys-to-BRIN-consistent-function-a-20180320.patch.gz application/gzip 5.4 KB
0002-Move-IS-NOT-NULL-checks-to-bringetbitmap-20180320.patch.gz application/gzip 2.9 KB
0003-BRIN-bloom-indexes-20180320.patch.gz application/gzip 17.6 KB
0004-BRIN-multi-range-minmax-indexes-20180320.patch.gz application/gzip 27.9 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2018-03-21 00:50:08 Re: JIT compiling with LLVM v12.2
Previous Message Daniel Gustafsson 2018-03-20 23:58:11 Re: [HACKERS] Optional message to user when terminating/cancelling backend