Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lJkba-0005zT-9f for pgsql-hackers@arkaria.postgresql.org; Tue, 09 Mar 2021 22:13:30 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lJkbZ-0004Kb-1k for pgsql-hackers@arkaria.postgresql.org; Tue, 09 Mar 2021 22:13:29 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lJkbY-0004K4-Ld for pgsql-hackers@lists.postgresql.org; Tue, 09 Mar 2021 22:13:28 +0000 Received: from mail-ed1-x531.google.com ([2a00:1450:4864:20::531]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1lJkbU-0006fj-Ml for pgsql-hackers@lists.postgresql.org; Tue, 09 Mar 2021 22:13:27 +0000 Received: by mail-ed1-x531.google.com with SMTP id bd6so23549814edb.10 for ; Tue, 09 Mar 2021 14:13:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb-com.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=c6ORa0xc+cXH/h7ELpPPxVn2UjxbwGcklOqUHl9dqkw=; b=Y8QHMyT8OWjmt/elFvP8EsoGzLUHzPnwQMuNlJmBCcxarLn8C++ITDVeWWW7V01uLK MHg5xQs5M8+5wryW8txs8AQXMRX6tH+wsgk6lcBgb2LEdHoC+1zVSjiDunGwx1CBf93K ciMUpWZhGal56+HrM/zlichbfxhDg6Bn5kCpiGOby6Vb4bBD/SehSiA0u5RZZrucHOUZ qvL58nORCAiHPfgTlQ3eQljQJedJEnMgFqSOqtV++nPEyUP8l8PILSkURXLooPaZl2y8 MDO3ylr6FrpukHSJ2K5DhK5vpnMlQxNtcskEUyn1NdQwKR6DIsdub9Uq0wnfkQNVsPTO 1zsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=c6ORa0xc+cXH/h7ELpPPxVn2UjxbwGcklOqUHl9dqkw=; b=DeuaO5gwIPzogAPW+R3/GXcrZf1uIWp8xRHOg34OZ+lgXAwkLy/LzRnIG/OdvN48d2 LzoiDpuR5pFreQbaETj4KQYfSqseqrNrqR3Ewyf0Kribr4dx/0UgyTjorBodrbgy+dMJ N2CHfm4gT7EOi7QqwIEMKTyBLPozUgccJ5np9mYot8oXr1ByedVQaJlLjuzipEkVj/m8 L0xn+TiOjZh0xj675TfGZsn0aKMuk9K5CWvdxDHwMKf5M+N01tZkavEkRhNvFmAqha7G z0S5fXjx5zl+TRIl5atCiWU30SGNEFW92muaps5iFOvgY8EFTu3Q2+3CBuTX9dGXRQFr Yavw== X-Gm-Message-State: AOAM532z2WCmhWMMo0t3sdEn9Z7ewodHemobvIy4hyeVXsQBgTJw+3xU LAiXpS+bbX2vXFV1jR96dE4ddPaOe+V/N5q8qznIMbOJA9Lci609EoegY8l2Zs0ciZrRJwPCIrp IbJIeCNvp7N/z6W0iu4LxzOkgnAUqmaIFwCysM85iAQAGUQctexmoHY8saEur6mOvSxpQWp9Gfw 5Wf5yadTH2am4mazJCybeZFlHtpIs2atgZGj4ppFLQSEQwseXYpOYHlKZKBHTIrszgmvYuUxeGf P1P0BNdv8bY7+a0RzfcSmjc3binu7xzi4QXxiSWRMOJCPM1ZmBYdA== X-Google-Smtp-Source: ABdhPJxQr9kWeDGj6WBh7/jOde1fYZUlgiEKI5tNTv6r9I7IR+sF0MwX0zDrYVEw+JVmoF8O0aK9AQ== X-Received: by 2002:a05:6402:b48:: with SMTP id bx8mr6864500edb.162.1615328003019; Tue, 09 Mar 2021 14:13:23 -0800 (PST) Received: from [10.137.0.20] (ip-86-49-253-127.net.upcbroadband.cz. [86.49.253.127]) by smtp.gmail.com with ESMTPSA id m7sm8922924ejk.52.2021.03.09.14.13.21 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 09 Mar 2021 14:13:21 -0800 (PST) Subject: Re: WIP: BRIN multi-range indexes To: John Naylor Cc: Alvaro Herrera , PostgreSQL Hackers References: <20210303001725.GA1766@alvherre.pgsql> <23a0a854-8f1a-e965-7121-f76b1b2fc271@enterprisedb.com> <8e319879-32ff-1eb8-d7d3-6a3ac8a51728@enterprisedb.com> From: Tomas Vondra Message-ID: <35e866e9-d820-07de-b2be-69d5ac479179@enterprisedb.com> Date: Tue, 9 Mar 2021 23:13:19 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-CLOUD-SEC-AV-Info: enterprisedb,google_mail,monitor X-CLOUD-SEC-AV-Sent: true X-Gm-Spam: 0 X-Gm-Phishy: 0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 3/9/21 9:51 PM, John Naylor wrote: > > On Sun, Mar 7, 2021 at 8:53 PM Tomas Vondra > > > wrote: > [v20210308b] > > I managed to trap an assertion that somehow doesn't happen during the > regression tests. The callers of fill_expanded_ranges() do math like this: > > /* both ranges and points are expanded into a separate element */ > neranges = ranges->nranges + ranges->nvalues; > > but inside fill_expanded_ranges() we have this assertion: > > /* Check that the output array has the right size. */ > Assert(neranges == (2 * ranges->nranges + ranges->nvalues)); > Yeah, that assert is bogus. It's calculating the number of boundary values (and ranges have two), but in ExpandedRanges each we still represent that as a single element. So the Assert should be just Assert(neranges == (ranges->nranges + ranges->nvalues)); But maybe it's just an overkill and we don't really need it. > In the regression test data, a debugging elog() shows that nranges is > most often zero, so in that case, the math happens to be right either > way. I can reliably get nranges above zero by running > > update brintest_multi set int8col = int8col - 1; > > a few times, at which point I get the crash. > Hmm, so maybe we should do something like this in regression tests too? It's not good that we don't trigger the "nranges > 0" case at all. > > Aside from that, the new changes look good. Just a couple small things: > > +    allowed parameters.  Only the bloom operator class > +    allows specifying parameters: > > minmax-multi aren't mentioned here, but are mentioned further down. > I forgot to add this bit. Will fix. > + * Addresses from different families are consider to be in maximum > > (comment above brin_minmax_multi_distance_inet) > s/consider/considered/ > Will fix. >> > 2) moving minmax/inclusion changes from 0002 to a separate patch 0003 >> > >> > I think we should either ditch the 0003 (i.e. keep the existing >> > opclasses unchanged) or commit 0003 (in which case I'd vote to just stop >> > supporting the old signature of the consistent function). >> > >> >> Still not sure what do to about this. I'm leaning towards keeping 0003 >> and just removing the "old" signature entirely, to keep the API cleaner. >> It might cause some breakage in out-of-core BRIN opclasses, but that >> seems like a reasonable price. Moreover, the opclasses may need some >> updating anyway, because of the changes in handling NULL scan keys (0004 >> moves that from the opclass to the bringetbitmap function). > > Keeping 0003 seems reasonable, given the above. > And do you agree with removing the old signature entirely? That might break some out-of-core opclasses, but we're not aware of any, and they'll be broken anyway. Seems fine to me. >> > The remaining part that didn't get much review is the very last patch, >> > adding an option to ignore correlation for some BRIN opclases. This is >> > needed as the regular BRIN costing is quite sensitive to correlation, >> > and the cost gets way too high for poorly correlated data, making it >> > unlikely the index will be used. But handling such data sets efficiently >> > is the main point of those new opclasses. Any opinions on this? >> > >> >> Not sure about this. > > I hadn't given it much thought (nor tested), but I just took a look at > brincostestimate(). If the table is badly correlated, I'm thinking the > number of ranges that need to be scanned will increase regardless. Maybe > rather than ignoring correlation, we could clamp it or otherwise tweak > it. Not sure about the details, though, that would require some testing. > Well, maybe. In any case we need to do something about this, otherwise the new opclasses won't be used even in cases where it's perfectly OK. And it needs to be opclass-dependent, in some way. I'm pretty sure even the simple examples you've used to test minmax-multi (with updating a fraction of tuples to low/high value) would be affected by this. regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company