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 1kG6A0-0005X7-6q for pgsql-hackers@arkaria.postgresql.org; Wed, 09 Sep 2020 19:53:40 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kG69y-0003HP-HS for pgsql-hackers@arkaria.postgresql.org; Wed, 09 Sep 2020 19:53:38 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kG69y-0003HG-At for pgsql-hackers@lists.postgresql.org; Wed, 09 Sep 2020 19:53:38 +0000 Received: from mail-qk1-x744.google.com ([2607:f8b0:4864:20::744]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1kG69u-00072h-0S for pgsql-hackers@postgresql.org; Wed, 09 Sep 2020 19:53:37 +0000 Received: by mail-qk1-x744.google.com with SMTP id f142so3628901qke.13 for ; Wed, 09 Sep 2020 12:53:33 -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=eWJkN9tlPHq1m72JKg4sMv4YTRMhNIWVm67lg1iuRBo=; b=OMYCQv/BOzdhCCJONNIHOl6AXrYD6SIRlKNTp54JDX0G5Vw4g3N5WMqa0F7FHjaSUa nm9a3hDdMhUSmiqI9be/XFhyHPDqRE7h4z6cn9J9AFPjbZZ6pRsnbaVc4XgJdudkaFug pF7FEefmeJFZP1NX/q1QYFOwExKiZIUFsISS9BkLf3+cX+x1VAnlOOlfR9xmvpQ6cGjK +5VCEkavvhCniggdNFWTY653jkXpYOgQUxf3MiDDTBJbrhTDb/4k/gJ4CHLcjj98nxMS uL6weOe6WSQmTwAReQZVxxj626WWcMkSFpHNSoyrep346P/WDG7ruY1LxPSIzLh48NaR nibQ== 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=eWJkN9tlPHq1m72JKg4sMv4YTRMhNIWVm67lg1iuRBo=; b=Y12fjC80oKCQ6spdPyi1VvNxp4nAt5+7KPTd7lSfNihoIyHDkXXM3uTXuMc1nJy3bo lNrvDchRbLaz1oPVhV6pK1cwO3sbrAbZiRwlhSExX65dcq4L8zOMWE6kM6t2xkbFjh+i bs0w5gQkJOKjK7r79onwPDiKtghRgiWYTu+8YhdT4RXzbYiKsmlo/hvaU19CCsSn1bLP H7Ui2vEdZbazf8pJQxWyy1y6GKPDMZB6No/dAZFfL3yvxpK2AlXMxwvM6qHoRiO1hC4/ FFgtPLJtIG16q9eZJYXFcB1LiMiFq9kjKZhZFHUB0iq+R5vbPi1tL5Kx/z6nnZLwmK/a 2rHw== X-Gm-Message-State: AOAM532zam8UmrCWVsrE4QluHMMfOhat9BeWVNd8RApNJVdHt1d+XV+G ry96Q/MbaDV33vy0mpsY8ITtBQ== X-Google-Smtp-Source: ABdhPJxUH9SByeg52dvnzFQLLN27b94k7TIFx/UJOPcuihf2CeNWArhA4p579tzz09oxNrwV7Oy09w== X-Received: by 2002:a37:414f:: with SMTP id o76mr4668952qka.162.1599681212894; Wed, 09 Sep 2020 12:53:32 -0700 (PDT) Received: from perhan.alvh.no-ip.org ([190.95.19.47]) by smtp.gmail.com with ESMTPSA id g5sm4050407qtx.43.2020.09.09.12.53.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Sep 2020 12:53:32 -0700 (PDT) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id B64EF2A1997; Wed, 9 Sep 2020 16:53:30 -0300 (-03) Date: Wed, 9 Sep 2020 16:53:30 -0300 From: Alvaro Herrera To: Tomas Vondra Cc: John Naylor , pgsql-hackers Subject: Re: WIP: BRIN multi-range indexes Message-ID: <20200909195330.GA16854@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20200909193530.x57p5nzawryndxzj@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-09, Tomas Vondra wrote: > There are some minor optimizations possible - for example I noticed we > call minmax_multi_get_strategy_procinfo often because it happens in a > loop, and we could easily do it just once. But that saves only about 10% > or so, it's not a ground-breaking optimization. Well, I guess this kind of thing should be fixed regardless while we still know it's there, just to avoid an obvious inefficiency. > The main reason for the slowness is that we pass the values one by one > to brin_minmax_multi_add_value - and on each call we need to deserialize > (and then sometimes also serialize) the summary, which may be quite > expensive. The regular minmax does not have this issue, it just swaps > the Datum value and that's it. Ah, right, that's more interesting. The original dumb BRIN code separates BrinMemTuple from BrinTuple so that things can be operated efficiently in memory. Maybe something similar can be done in this case, which also sounds like your second suggestion: > Another option would be to teach add_value to keep the deserialized > summary somewhere, and then force serialization at the end of the BRIN > page range. The end result would be roughly the same, I think. Also, I think you could get a few initial patches pushed soon, since they look like general improvements rather than specific to multi-range. On a differen train of thought, I wonder if we shouldn't drop the idea of there being two minmax opclasses; just have one (still called "minmax") and have the multi-range version be the v2 of it. We would still need to keep code to operate on the old one, but if you ever REINDEX then your index is upgraded to the new one. I see no reason to keep the dumb minmax version around, assuming the performance is roughly similar. -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services