Re: COPY FREEZE and setting PD_ALL_VISIBLE/visibility map bits
Anastasia Lubennikova <a.lubennikova@postgrespro.ru>
From: Anastasia Lubennikova <a.lubennikova@postgrespro.ru>
To: Tomas Vondra <tomas.vondra@2ndquadrant.com>
Cc: Tatsuo Ishii <ishii@sraoss.co.jp>, lubennikovaav@gmail.com,
pgsql-hackers@lists.postgresql.org, pavan.deolasee@gmail.com,
ibrar.ahmad@gmail.com
Date: 2021-01-11T21:00:39Z
Lists: pgsql-hackers
Attachments
On 11.01.2021 01:35, Tomas Vondra wrote: > Hi, > > I started looking at this patch again, hoping to get it committed in > this CF, but I think there's a regression in handling TOAST tables > (compared to the v3 patch submitted by Pavan in February 2019). > > The test I'm running a very simple test (see test.sql): > > 1) start a transaction > 2) create a table with a text column > 3) copy freeze data into it > 4) use pg_visibility to see how many blocks are all_visible both in the > main table and it's TOAST table > > For v3 patch (applied on top of 278584b526 and > s/hi_options/ti_options) I get this: > > pages NOT all_visible > ------------------------------------------ > main 637 0 > toast 50001 3 > > There was some discussion about relcache invalidations causing a > couple TOAST pages not be marked as all_visible, etc. > > However, for this patch on master I get this > > pages NOT all_visible > ------------------------------------------ > main 637 0 > toast 50001 50001 > > So no pages in TOAST are marked as all_visible. I haven't investigated > what's causing this, but IMO that needs fixing to make ths patch RFC. > > Attached is the test script I'm using, and a v5 of the patch - rebased > on current master, with some minor tweaks to comments etc. > Thank you for attaching the test script. I reproduced the problem. This regression occurs because TOAST internally uses heap_insert(). You have asked upthread about adding this optimization to heap_insert(). I wrote a quick fix, see the attached patch 0002. The TOAST test passes now, but I haven't tested performance or any other use-cases yet. I'm going to test it properly in a couple of days and share results. With this change a lot of new code is repeated in heap_insert() and heap_multi_insert(). I think it's fine, because these functions already have a lot in common. -- Anastasia Lubennikova Postgres Professional: http://www.postgrespro.com The Russian Postgres Company
Commits
-
Fix COPY FREEZE with CLOBBER_CACHE_ALWAYS
- 39b66a91bdeb 14.0 landed
-
Set PD_ALL_VISIBLE and visibility map bits in COPY FREEZE
- 7db0cd2145f2 14.0 landed
-
docs: client certificates are always sent to the server
- ff60394a8c9a 14.0 cited
-
Mark commit and abort WAL records with XLR_SPECIAL_REL_UPDATE.
- a28d731a1187 14.0 cited
-
docs: land height is "elevation", not "altitude"
- 92c12e46d5f1 13.0 cited
-
Improve the internal implementation of ereport().
- 17a28b03645e 13.0 cited