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 1kGSlQ-0006rR-4s for pgsql-hackers@arkaria.postgresql.org; Thu, 10 Sep 2020 20:01:48 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kGSlN-0007Zv-HX for pgsql-hackers@arkaria.postgresql.org; Thu, 10 Sep 2020 20:01:45 +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 1kGSlN-0007Zo-6d for pgsql-hackers@lists.postgresql.org; Thu, 10 Sep 2020 20:01:45 +0000 Received: from mail-qk1-x742.google.com ([2607:f8b0:4864:20::742]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1kGSlJ-00070p-W5 for pgsql-hackers@postgresql.org; Thu, 10 Sep 2020 20:01:44 +0000 Received: by mail-qk1-x742.google.com with SMTP id w186so7420908qkd.1 for ; Thu, 10 Sep 2020 13:01:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=u67XJO/PlAdvyVNr4IRaZyzHXv29BqueZ1cG+eKUr8Q=; b=BdUS+5lqZdAREUfWj+9sFHiG+2weRgNABP3ECEW9EOUq+FD0yZxmjnPTdix270XmkG mRM9IXlnuszGVAC7gOIsXHg7wzVcV+ZTLkAAI8WPbNczg8DrNBuNgH++//+9aI2szlI2 6c0VlanUHYnwBgx4mWQiOBDdEY41AvzTfzafGi5PF8iF4QnYJZslRD75MgtnEg/GAtWN QgRI7yTrzHw02c97ExgMmdov5yX4hgAXB1jA4/JpIlMmYIfPHxJKuHohQV6ch2/WL36S r3EvQks4f/tkOyS93Yxg22kxIG/60r3NSiKhw1ePJQk+Bs14zrR6YNQT8Tla5ed2cBB7 yl8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=u67XJO/PlAdvyVNr4IRaZyzHXv29BqueZ1cG+eKUr8Q=; b=LyiYwkRLovDhkL6iQZ+HZoRVwMgxRcYOw3nlzC/OyjTIamqVj1LkaEgdE99GEvzXLL r466TLLJJdj88TAZoV47ih31N/+ARRIx5/dpHAroNRXx1Q7bIBk/ZT7BBVqHYbPzTgue S45Q+ZP+k43/+iRgGcIQDl+Lw86j7ISZq3IbpGPE+o7Sc+MEstFUg8VuIO7K/fNdpChD p3PIOOEV1hn8MjCxKW8Ssw2a2g19vlXyCZDADbsvoq+biJ7xuV6HpTnYfKGkrImPQ67N EaCaelqM3J8cP6yMqI1BldyHP6xiLhxrji+3DOsmkprCunCC4bPLrtLdX/z2XQAwwzXs lyWg== X-Gm-Message-State: AOAM531q1vkyFe9Pn8JCgxpXTOgLSB1v72JGZb6Md4FVtftsSJWwzak4 Wx30O8Sk9lCs8i8Fy/VIaCGxuQ== X-Google-Smtp-Source: ABdhPJzxapmjiuDvXSLgVUk/tco8yZBWaWsCELfxNiaZC6OHqomBK5y2xL/Rj1ZP84IrLh1pw172Og== X-Received: by 2002:a05:620a:2442:: with SMTP id h2mr9462847qkn.225.1599768099904; Thu, 10 Sep 2020 13:01:39 -0700 (PDT) Received: from perhan.alvh.no-ip.org ([190.95.19.47]) by smtp.gmail.com with ESMTPSA id v30sm8388001qtj.52.2020.09.10.13.01.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2020 13:01:39 -0700 (PDT) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id 823FB2A153C; Thu, 10 Sep 2020 17:01:37 -0300 (-03) Date: Thu, 10 Sep 2020 17:01:37 -0300 From: Alvaro Herrera To: Tomas Vondra Cc: John Naylor , pgsql-hackers Subject: Re: WIP: BRIN multi-range indexes Message-ID: <20200910200137.GA25491@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20200910183248.eajizgzuypntsjmh@development> User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2020-Sep-10, Tomas Vondra wrote: > I've spent a bit of time experimenting with this. My idea was to allow > keeping an "expanded" version of the summary somewhere. As the addValue > function only receives BrinValues I guess one option would be to just > add bv_mem_values field. Or do you have a better idea? Maybe it's okay to pass the BrinMemTuple to the add_value function, and keep something there. Or maybe that's pointless and just a new field in BrinValues is okay. > Of course, more would need to be done: > > 1) We'd need to also pass the right memory context (bt_context seems > like the right thing, but that's not something addValue sees now). You could use GetMemoryChunkContext() for that. > 2) We'd also need to specify some sort of callback that serializes the > in-memory value into bt_values. That's not something addValue can do, > because it doesn't know whether it's the last value in the range etc. I > guess one option would be to add yet another support proc, but I guess a > simple callback would be enough. Hmm. > I've hacked together an experimental version of this to see how much > would it help, and it reduces the duration from ~4.6s to ~3.3s. Which is > nice, but plain minmax is ~1.1s. I suppose there's room for further > improvements in compare_combine_ranges/reduce_combine_ranges and so on, > but I still think there'll always be a gap compared to plain minmax. The main reason I'm talking about desupporting plain minmax is that, even if it's amazingly fast, it loses quite quickly in real-world cases because of loss of correlation. Minmax's build time is pretty much determined by speed at which you can seqscan the table. I don't think we lose much if we add overhead in order to create an index that is 100x more useful. -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services