Re: BRIN minmax multi - incorrect distance for infinite timestamp/date

From: Tomas Vondra <tomas(dot)vondra(at)enterprisedb(dot)com>
To: Ashutosh Bapat <ashutosh(dot)bapat(dot)oss(at)gmail(dot)com>
Cc: Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: BRIN minmax multi - incorrect distance for infinite timestamp/date
Date: 2023-10-17 20:25:38
Message-ID: 31400145-6f71-a6b2-e371-048a8e1584ef@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

Here's a couple cleaned-up patches fixing the various discussed here.
I've tried to always add a regression test demonstrating the issue
first, and then fix it in the next patch.

In particular, this deals with these issues:

1) overflows in distance calculation for large timestamp values (0002)

2) incorrect subtraction in distance for date values (0003)

3) incorrect distance for infinite date/timestamp values (0005)

4) failing distance for extreme interval values (0007)

All the problems except "2" have been discussed earlier, but this seems
a bit more serious than the other issues, as it's easier to hit. It
subtracts the values in the opposite order (smaller - larger), so the
distances are negated. Which means we actually merge the values from the
most distant ones, and thus are "guaranteed" to build very a very
inefficient summary. People with multi-minmax indexes on "date" columns
probably will need to reindex.

regards

--
Tomas Vondra
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

Attachment Content-Type Size
0001-Tests-for-overflows-with-dates-and-timestamps-in-BRI.patch text/x-patch 9.2 KB
0002-Fix-overflow-in-brin_minmax_multi_distance_timestamp.patch text/x-patch 1011 bytes
0003-Fix-calculation-in-brin_minmax_multi_distance_date.patch text/x-patch 1.2 KB
0004-Add-tests-for-inifite-date-timestamp-values.patch text/x-patch 8.0 KB
0005-Fix-handling-of-infinity-date-timestamp-values.patch text/x-patch 1.6 KB
0006-Add-test-for-BRIN-minmax-multi-with-extreme-interval.patch text/x-patch 3.2 KB
0007-Fix-distance-calculation-for-extreme-interval-values.patch text/x-patch 2.6 KB
0008-Add-more-tests-for-BRIN-on-interval-values.patch text/x-patch 4.5 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jelte Fennema 2023-10-17 20:43:04 Re: run pgindent on a regular basis / scripted manner
Previous Message Stephen Frost 2023-10-17 20:20:58 Re: [PoC/RFC] Multiple passwords, interval expirations