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 1kG6fS-00070G-BK for pgsql-hackers@arkaria.postgresql.org; Wed, 09 Sep 2020 20:26:10 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kG6fR-0002lT-9K for pgsql-hackers@arkaria.postgresql.org; Wed, 09 Sep 2020 20:26:09 +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 1kG6fR-0002kw-2W for pgsql-hackers@lists.postgresql.org; Wed, 09 Sep 2020 20:26:09 +0000 Received: from mail-ed1-x541.google.com ([2a00:1450:4864:20::541]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1kG6fN-0007IS-1d for pgsql-hackers@postgresql.org; Wed, 09 Sep 2020 20:26:07 +0000 Received: by mail-ed1-x541.google.com with SMTP id w1so4026119edr.3 for ; Wed, 09 Sep 2020 13:26:04 -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:references:mime-version :content-disposition:in-reply-to; bh=85bbnJT0VOjWZCLzBpZd63CKljyBYqWTZxsm0qwkPo8=; b=TD2r0o2dpJoLgFQamIV5S/Fr7IeCESWw38e6cOX3uVa3SBQBIuDvF1cViSziws7Wt6 rrVIRMqqNcViawYu9TdaSOayuaoriVzRXxXTZw/PZI+C9MVqJqJ2vYmphM73WXupQ90Y WrfPfXXl06W7oHJxvBfjHv8RQ/vBj17rIw4Z271X9RBJXS/bSV8hkglK3MAKXAiNuyj6 TJwBQweD6171lNCBySW35FrCe6FqsbvpNXcKXjMTIxcU1UgwBlcoA2J3G2csd1DuANZd DVQpRDBWCe/uiWPQ2wG1kWq+CwgZJJykg+lhc5MQfL0ARc8vPvm4mpGg39sb061U7OET bI6g== 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:references :mime-version:content-disposition:in-reply-to; bh=85bbnJT0VOjWZCLzBpZd63CKljyBYqWTZxsm0qwkPo8=; b=pcf1kxiwVfkYOhqF7gfBHzPVyw5k79dWfj8rPUUIEce1MrJvdFjn6reRx3c7roPDau 9d5st3Z6oMsbXxyXXGG0zMk7nhGad9wuzpUtMlVOWucBeSDS2FSjsKZgcdp/eLAoAHlT nUEBIvSq1b0AOlfCpqoEAhAaoIpOAXcAWDH1h4OlLxeSoKZvLPjtnb0bj5yEvCXkkgYE poBEj+JCDi2zhj5setT4q+qJupMCNtwCiDirXR4yma2WLO5oG978uO9fLWw9dNmL9a83 /M42sx+owKc4fY8PKE2XeU2CSRAO8mCo0Elm2tP1It+a+KHV3wRT8NdWO2Iv9TKYubzo FvDw== X-Gm-Message-State: AOAM530EwfTjwPJeW6HBuK421OQWFGsq9fNMUxez6LxYoGy0KrOWX/zF v37jPJGyVgJSReuRrxFjxkeLCQ== X-Google-Smtp-Source: ABdhPJwX5vocJPadEyAw1D4kqE1MUvbZeVL8E1f4+oQP1RPGnetIKuBS13JjZ57+7g0Nx1SK2Z6PxQ== X-Received: by 2002:a50:bf4a:: with SMTP id g10mr5889302edk.188.1599683162900; Wed, 09 Sep 2020 13:26:02 -0700 (PDT) Received: from localhost (ip-86-49-253-216.net.upcbroadband.cz. [86.49.253.216]) by smtp.gmail.com with ESMTPSA id r8sm3670422edy.87.2020.09.09.13.26.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Sep 2020 13:26:02 -0700 (PDT) Date: Wed, 9 Sep 2020 22:26:00 +0200 From: Tomas Vondra To: Alvaro Herrera Cc: John Naylor , pgsql-hackers Subject: Re: WIP: BRIN multi-range indexes Message-ID: <20200909202600.fup27xfr2m34jqg6@development> References: <20200909193530.x57p5nzawryndxzj@development> <20200909195330.GA16854@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20200909195330.GA16854@alvherre.pgsql> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Wed, Sep 09, 2020 at 04:53:30PM -0300, Alvaro Herrera wrote: >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. > Sure. I was just suggesting it's not something that'd make this very close to plain minmax opclass. >> 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. > Well, the patch already has Ranges (memory) and SerializedRanges (disk) but it's not very clear to me where to stash the in-memory data and where to make the conversion. > >Also, I think you could get a few initial patches pushed soon, since >they look like general improvements rather than specific to multi-range. > Yeah, I agree. I plan to review those once again in a couple days and then push them. > >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. > I'm not a huge fan of that. I think it's unlikely we'll ever make this new set of oplasses just as fast as the plain minmax, and moreover it does have some additional requirements (e.g. the distance proc, which may not make sense for some data types). regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services