pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tomas Vondra <tomas.vondra@enterprisedb.com>
To: Dean Rasheed <dean.a.rasheed@gmail.com>
To: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Subject: Re: BRIN minmax multi - incorrect distance for infinite timestamp/date
Date: Thu, 19 Oct 2023 11:05:45 +0200
Message-ID: <589f9827-2d4c-90ac-0ce2-84b83c5e4c0c@enterprisedb.com> (raw)
In-Reply-To: <CAEZATCVquhefWxc56AW0wtN2_ztXn85qPs5sEOptFDD-p+nxCg@mail.gmail.com>
References: <eef0ea8c-4aaa-8d0d-027f-58b1f35dd170@enterprisedb.com>
	<CAEZATCWwqTdcBC1ee1uLp+KG4XZLmxFwEGX9y9sBLUR+OdQHeA@mail.gmail.com>
	<14c205c6-fbf4-d2f2-3ea8-a7d5c5d63180@enterprisedb.com>
	<CAEZATCUNjgmTfTJnkR+DMXfRbrm+bqJuEZ-fKRJF3X4mr=o3LQ@mail.gmail.com>
	<75de1895-3bd9-242e-cf13-3f5b0281e676@enterprisedb.com>
	<CAEZATCV0kY0gWCLChf_x_Drh4KUEKcmBPD+cggcSju6yHaRYYA@mail.gmail.com>
	<CAExHW5tsrfu3k5We1tr_ANaQ_0OJc6Zf2YMB+TkmB2PQwirAPQ@mail.gmail.com>
	<dd7fcf77-414b-b4b2-358a-0fc505255fba@enterprisedb.com>
	<CAExHW5vcq6mJJRH3wPytDataDw+HZgs-E7b=e+SXpWgo7BoTsg@mail.gmail.com>
	<31400145-6f71-a6b2-e371-048a8e1584ef@enterprisedb.com>
	<CAExHW5vi3Yjk_5vvwtZWrvy-ZWbx68hbET_GpyH5fjS=2KMZrw@mail.gmail.com>
	<575aa0fe-311d-d3d0-1f1a-abb1b9665a63@enterprisedb.com>
	<CAExHW5vThLf2BKHYfj5SJjsrotHe-zaDiZwS0k27BW_FP4nXaA@mail.gmail.com>
	<CAEZATCVquhefWxc56AW0wtN2_ztXn85qPs5sEOptFDD-p+nxCg@mail.gmail.com>



On 10/19/23 09:04, Dean Rasheed wrote:
> On Thu, 19 Oct 2023, 05:32 Ashutosh Bapat, <ashutosh.bapat.oss@gmail.com
> <mailto:ashutosh.bapat.oss@gmail.com>> wrote:
> 
>     On Wed, Oct 18, 2023 at 8:23 PM Tomas Vondra
>     <tomas.vondra@enterprisedb.com
>     <mailto:tomas.vondra@enterprisedb.com>> wrote:
> 
>     >
>     > I did use that many values to actually force "compaction" and
>     merging of
>     > points into ranges. We only keep 32 values per page range, so with 2
>     > values we'll not build a range. You're right it may still trigger the
>     > overflow (we probably still calculate distances, I didn't realize
>     that),
>     > but without the compaction we can't check the query plans.
>     >
>     > However, I agree 60 values may be a bit too much. And I realized
>     we can
>     > reduce the count quite a bit by using the values_per_range option. We
>     > could set it to 8 (which is the minimum).
>     >
> 
>     I haven't read BRIN code, except the comments in the beginning of the
>     file. From what you describe it seems we will store first 32 values as
>     is, but later as the number of values grow create ranges from those?
>     Please point me to the relevant source code/documentation. Anyway, if
>     we can reduce the number of rows we insert, that will be good.
> 
> 
> I don't think 60 values is excessive, but instead of listing them out by
> hand, perhaps use generate_series().
> 

I tried to do that, but I ran into troubles with the "date" tests. I
needed to build values that close to the min/max values, so I did
something like

SELECT '4713-01-01 BC'::date + (i || ' days')::interval FROM
generate_series(1,10) s(i);

And then the same for the max date, but that fails because of the
date/timestamp conversion in date plus operator.

However, maybe two simple generate_series() would work ...

regards

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





view thread (27+ messages)  latest in thread

Message-ID: <589f9827-2d4c-90ac-0ce2-84b83c5e4c0c@enterprisedb.com>
Permalink:  ../589f9827-2d4c-90ac-0ce2-84b83c5e4c0c@enterprisedb.com/
Also on:    postgresql.org/message-id/589f9827-2d4c-90ac-0ce2-84b83c5e4c0c@enterprisedb.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: tomas.vondra@enterprisedb.com, dean.a.rasheed@gmail.com, ashutosh.bapat.oss@gmail.com, pgsql-hackers@lists.postgresql.org
  Subject: Re: BRIN minmax multi - incorrect distance for infinite timestamp/date
  In-Reply-To: <589f9827-2d4c-90ac-0ce2-84b83c5e4c0c@enterprisedb.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox