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 1n6WNF-0001U5-HW for pgsql-hackers@arkaria.postgresql.org; Sun, 09 Jan 2022 11:28:33 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1n6WND-0004z2-0d for pgsql-hackers@arkaria.postgresql.org; Sun, 09 Jan 2022 11:28:31 +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 1n6WNC-0004yt-Mr for pgsql-hackers@lists.postgresql.org; Sun, 09 Jan 2022 11:28:30 +0000 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1n6WN5-0007iO-Kh for pgsql-hackers@lists.postgresql.org; Sun, 09 Jan 2022 11:28:30 +0000 Received: by mail-wr1-x433.google.com with SMTP id v6so21139005wra.8 for ; Sun, 09 Jan 2022 03:28:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kontur.io; s=google2; h=subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=NM5rAlW/A6+fkxz8jStzZpHXlOWFEgeCTe4wIqcs7mA=; b=Ku3PsBEjWwnsVefixh6EscXlPtV2Kz/4WAN7TG/Xaqh55PjvIgdPlrQoaj931iE+JB ItaTnPa3azQwGOdY3B6pxqtRq9+PCBLuqSJe4OMyfRUh+Z5+qUoDHeWMU454GxbHutsR o0f8dlV6Qmi3I2A0WKV8584P2gKSd4E6cechw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=NM5rAlW/A6+fkxz8jStzZpHXlOWFEgeCTe4wIqcs7mA=; b=hdxSRTbFB/PtAybtbERPEW+8JfGLCuXat39n4UuYjIcoYqK7y6m7zAC6yy3CYXfrm7 PR+LuqZZw7AaPKOuhGwGIzf0BWVBlURqWsJhknxTUjnlfC5oE+E1Nc9cGzfhkYm6YusH NW0OXbOpWmvP5PVvYX9oFTQ9KF6d42xEwgsJFHjTrkgpbg+o0Q68/f2YS1f4ui3kioYJ ENK9qYRR70xuVUXqux7mgwCwxj3lFB96wetWvcnUaIVkw2R55PYw92nLsmj8Ugkn0Pr4 LptohfI+mb6KCfb25vrCqHV182py3XllyIIAsu6hPJPKBpNA+MI16IOtpj6cmcxAkRHO N0BA== X-Gm-Message-State: AOAM531E6wTraffjhSR6UdXFRiGAv0RKTOHDX7P0by7tupbdDPDZJnlc hv10ay7+m+yxuuozUiZPLL/d+CECafNSmA== X-Google-Smtp-Source: ABdhPJyaLvBJbgylHzQjaMyLcT7mToL8IV2wCz/N5w+AoD65AqvejdPljEplBfFNX/CAEJki/kAs8A== X-Received: by 2002:a5d:4e44:: with SMTP id r4mr2978257wrt.593.1641727701413; Sun, 09 Jan 2022 03:28:21 -0800 (PST) Received: from [192.168.88.239] ([37.214.76.1]) by smtp.gmail.com with ESMTPSA id b16sm4292058wmq.41.2022.01.09.03.28.20 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 09 Jan 2022 03:28:21 -0800 (PST) Subject: Re: [PATCH] reduce page overlap of GiST indexes built using sorted method To: Aliaksandr Kalenik References: <23731640439330@vla1-4ea76ba32639.qloud-c.yandex.net> Cc: pgsql-hackers@lists.postgresql.org From: "sergei sh." Message-ID: <3aa6ba30-e9d8-10ef-753f-8deea5f196d0@kontur.io> Date: Sun, 9 Jan 2022 14:28:20 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, here are some benchmark results for GiST patch: https://gist.github.com/mngr777/88ae200c9c30ba5656583d92e8d2cf9e Code used for benchmarking: https://github.com/mngr777/pg_index_bm2, see README for the list of test queries. Results show query performance close to indexes built with no sortsupport function, with index creation time reduced approx. by half. On 1/8/22 10:20 PM, Aliaksandr Kalenik wrote: > After further testing, here is v2 where the issue that rightlink can be > set when an index page is already flushed is fixed. > > On Sat, Dec 25, 2021 at 4:35 PM Andrey Borodin > wrote: > > > Hi Aliaksandr! > > Thanks for working on this! > > > Benchmark summary: > > > > create index roads_rdr_idx on roads_rdr using gist (geom); > > > > with sort support before patch / CREATE INDEX 76.709 ms > > > > with sort support after patch / CREATE INDEX 225.238 ms > > > > without sort support / CREATE INDEX 446.071 ms > > > > select count(*) from roads_rdr a, roads_rdr b where a.geom && b.geom; > > > > with sort support before patch / SELECT 5766.526 ms > > > > with sort support after patch / SELECT 2646.554 ms > > > > without sort support / SELECT 2721.718 ms > > > > index size > > > > with sort support before patch / IDXSIZE 2940928 bytes > > > > with sort support after patch / IDXSIZE 4956160 bytes > > > > without sort support / IDXSIZE 5447680 bytes > > The numbers are impressive, newly build index is actually performing > better! > I've conducted some tests over points, not PostGIS geometry. For > points build is 2x slower now, but this is the cost of faster scans. > > Some strong points of this index building technology. > The proposed algorithm is not randomly chosen as anything that > performs better than the original sorting build. We actually > researched every idea we knew from literature and intuition. > Although we consciously limited the search area by existing GiST API. > Stuff like penalty-based choose-subtree and split in equal halves > seriously limit possible solutions. If anyone knows an any better > way to build GiST faster or with better scan performance - please > let us know. > The proposed algorithm contains the current algorithm as a special > case: there is a parameter - the number of buffers accumulated > before calling Split. If this parameter is 1 proposed algorithm will > produce exactly the same output. > > At this stage, we would like to hear some feedback from Postgres and > PostGIS community. What other performance aspects should we test? > > Current patch implementation has some known deficiencies: > 1. We need a GUC instead of the hard-coded buffer of 8 pages. > 2. Is GiST sorting build still deterministic? If not - we should add > a fixed random seed into pageinspect tests. > 3. It would make sense to check the resulting indexes with amcheck > [0], although it's not committed. > 4. We cannot make an exact fillfactor due to the behavior of > picksplit. But can we improve anything here? I think if not - it's > still OK. > 5. GistSortedBuildPageState is no more page state. It's Level state > or something like that. > 6. The patch desperately needs comments. > > > Thanks! > > Best regards, Andrey Borodin. > > [0] > https://www.postgresql.org/message-id/flat/59D0DA6B-1652-4D44-B0EF-A582D5824F83%40yandex-team.ru > >