pg.ddx.io pgsql-committers@postgresql.org mailing list archive
help / color / mirror / Atom feedpgsql: Skip full index scan during cleanup of B-tree indexes when possi
18+ messages / 6 participants
[nested] [flat]
* pgsql: Skip full index scan during cleanup of B-tree indexes when possi
@ 2018-04-04 16:29 Teodor Sigaev <teodor@sigaev.ru>
2018-04-04 22:32 ` Re: pgsql: Skip full index scan during cleanup of B-tree indexes when possi Alexander Korotkov <a.korotkov@postgrespro.ru>
2018-04-18 18:12 ` Re: pgsql: Skip full index scan during cleanup of B-tree indexes when possi Fujii Masao <masao.fujii@gmail.com>
0 siblings, 2 replies; 18+ messages in thread
From: Teodor Sigaev @ 2018-04-04 16:29 UTC (permalink / raw)
To: pgsql-committers@lists.postgresql.org
Skip full index scan during cleanup of B-tree indexes when possible
Vacuum of index consists from two stages: multiple (zero of more) ambulkdelete
calls and one amvacuumcleanup call. When workload on particular table
is append-only, then autovacuum isn't intended to touch this table. However,
user may run vacuum manually in order to fill visibility map and get benefits
of index-only scans. Then ambulkdelete wouldn't be called for indexes
of such table (because no heap tuples were deleted), only amvacuumcleanup would
be called In this case, amvacuumcleanup would perform full index scan for
two objectives: put recyclable pages into free space map and update index
statistics.
This patch allows btvacuumclanup to skip full index scan when two conditions
are satisfied: no pages are going to be put into free space map and index
statistics isn't stalled. In order to check first condition, we store
oldest btpo_xact in the meta-page. When it's precedes RecentGlobalXmin, then
there are some recyclable pages. In order to check second condition we store
number of heap tuples observed during previous full index scan by cleanup.
If fraction of newly inserted tuples is less than
vacuum_cleanup_index_scale_factor, then statistics isn't considered to be
stalled. vacuum_cleanup_index_scale_factor can be defined as both reloption and GUC (default).
This patch bumps B-tree meta-page version. Upgrade of meta-page is performed
"on the fly": during VACUUM meta-page is rewritten with new version. No special
handling in pg_upgrade is required.
Author: Masahiko Sawada, Alexander Korotkov
Review by: Peter Geoghegan, Kyotaro Horiguchi, Alexander Korotkov, Yura Sokolov
Discussion: https://www.postgresql.org/message-id/flat/CAD21AoAX+d2oD_nrd9O2YkpzHaFr=uQeGr9s1rKC3O4ENc568g@mail....
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/857f9c36cda520030381bd8c2af20adf0ce0e1d4
Modified Files
--------------
contrib/amcheck/verify_nbtree.c | 8 +-
contrib/pageinspect/Makefile | 3 +-
contrib/pageinspect/btreefuncs.c | 4 +-
contrib/pageinspect/expected/btree.out | 16 +--
contrib/pageinspect/pageinspect--1.6--1.7.sql | 26 +++++
contrib/pageinspect/pageinspect.control | 2 +-
contrib/pgstattuple/expected/pgstattuple.out | 10 +-
doc/src/sgml/config.sgml | 25 +++++
doc/src/sgml/pageinspect.sgml | 16 +--
doc/src/sgml/ref/create_index.sgml | 15 +++
src/backend/access/common/reloptions.c | 13 ++-
src/backend/access/nbtree/nbtinsert.c | 12 +++
src/backend/access/nbtree/nbtpage.c | 150 ++++++++++++++++++++++++--
src/backend/access/nbtree/nbtree.c | 118 ++++++++++++++++++--
src/backend/access/nbtree/nbtxlog.c | 6 +-
src/backend/utils/init/globals.c | 2 +
src/backend/utils/misc/guc.c | 10 ++
src/include/access/nbtree.h | 11 +-
src/include/access/nbtxlog.h | 4 +
src/include/miscadmin.h | 2 +
src/include/utils/rel.h | 2 +
src/test/regress/expected/btree_index.out | 29 +++++
src/test/regress/sql/btree_index.sql | 19 ++++
23 files changed, 458 insertions(+), 45 deletions(-)
^ permalink raw reply [nested|flat] 18+ messages in thread
* Re: pgsql: Skip full index scan during cleanup of B-tree indexes when possi
2018-04-04 16:29 pgsql: Skip full index scan during cleanup of B-tree indexes when possi Teodor Sigaev <teodor@sigaev.ru>
@ 2018-04-04 22:32 ` Alexander Korotkov <a.korotkov@postgrespro.ru>
2018-04-05 00:00 ` Re: pgsql: Skip full index scan during cleanup of B-tree indexes when possi Peter Geoghegan <pg@bowt.ie>
2018-04-05 11:16 ` Re: pgsql: Skip full index scan during cleanup of B-tree indexes when possi Alexander Korotkov <a.korotkov@postgrespro.ru>
1 sibling, 2 replies; 18+ messages in thread
From: Alexander Korotkov @ 2018-04-04 22:32 UTC (permalink / raw)
To: Teodor Sigaev <teodor@sigaev.ru>; +Cc: pgsql-committers@lists.postgresql.org
Hi!
On Wed, Apr 4, 2018 at 7:29 PM, Teodor Sigaev <teodor@sigaev.ru> wrote:
> Skip full index scan during cleanup of B-tree indexes when possible
>
Thank you for committing this.
It appears that patch contains some redundant variabled. See warnings
produced
by gcc-7.
nbtpage.c: In function '_bt_update_meta_cleanup_info':
nbtpage.c:121:15: warning: variable 'metaopaque' set but not used
[-Wunused-but-set-variable]
BTPageOpaque metaopaque;
^~~~~~~~~~
nbtree.c: In function '_bt_vacuum_needs_cleanup':
nbtree.c:790:15: warning: variable 'metaopaque' set but not used
[-Wunused-but-set-variable]
BTPageOpaque metaopaque;
^~~~~~~~~~
Attached patch fixes this.
------
Alexander Korotkov
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company
Attachments:
bt-vacuum-cleanup-fix-warnings.patch (application/octet-stream, 1.4K) download
diff --git a/src/backend/access/nbtree/nbtpage.c b/src/backend/access/nbtree/nbtpage.c
index 505a67e6ed..250cbf3f1c 100644
--- a/src/backend/access/nbtree/nbtpage.c
+++ b/src/backend/access/nbtree/nbtpage.c
@@ -118,7 +118,6 @@ _bt_update_meta_cleanup_info(Relation rel, TransactionId oldestBtpoXact,
{
Buffer metabuf;
Page metapg;
- BTPageOpaque metaopaque;
BTMetaPageData *metad;
bool needsRewrite = false;
XLogRecPtr recptr;
@@ -126,7 +125,6 @@ _bt_update_meta_cleanup_info(Relation rel, TransactionId oldestBtpoXact,
/* read the metapage and check if it needs rewrite */
metabuf = _bt_getbuf(rel, BTREE_METAPAGE, BT_READ);
metapg = BufferGetPage(metabuf);
- metaopaque = (BTPageOpaque) PageGetSpecialPointer(metapg);
metad = BTPageGetMeta(metapg);
/* outdated version of metapage always needs rewrite */
diff --git a/src/backend/access/nbtree/nbtree.c b/src/backend/access/nbtree/nbtree.c
index 06badc90ba..66a66f2dad 100644
--- a/src/backend/access/nbtree/nbtree.c
+++ b/src/backend/access/nbtree/nbtree.c
@@ -786,13 +786,11 @@ _bt_vacuum_needs_cleanup(IndexVacuumInfo *info)
{
Buffer metabuf;
Page metapg;
- BTPageOpaque metaopaque;
BTMetaPageData *metad;
bool result = false;
metabuf = _bt_getbuf(info->index, BTREE_METAPAGE, BT_READ);
metapg = BufferGetPage(metabuf);
- metaopaque = (BTPageOpaque) PageGetSpecialPointer(metapg);
metad = BTPageGetMeta(metapg);
if (metad->btm_version < BTREE_VERSION)
^ permalink raw reply [nested|flat] 18+ messages in thread
* Re: pgsql: Skip full index scan during cleanup of B-tree indexes when possi
2018-04-04 16:29 pgsql: Skip full index scan during cleanup of B-tree indexes when possi Teodor Sigaev <teodor@sigaev.ru>
2018-04-04 22:32 ` Re: pgsql: Skip full index scan during cleanup of B-tree indexes when possi Alexander Korotkov <a.korotkov@postgrespro.ru>
@ 2018-04-05 00:00 ` Peter Geoghegan <pg@bowt.ie>
2018-04-05 00:58 ` Re: pgsql: Skip full index scan during cleanup of B-tree indexes when possi Tom Lane <tgl@sss.pgh.pa.us>
1 sibling, 1 reply; 18+ messages in thread
From: Peter Geoghegan @ 2018-04-05 00:00 UTC (permalink / raw)
To: Alexander Korotkov <a.korotkov@postgrespro.ru>; +Cc: Teodor Sigaev <teodor@sigaev.ru>; pgsql-committers <pgsql-committers@lists.postgresql.org>
On Wed, Apr 4, 2018 at 3:32 PM, Alexander Korotkov
<a.korotkov@postgrespro.ru> wrote:
> Hi!
>
> On Wed, Apr 4, 2018 at 7:29 PM, Teodor Sigaev <teodor@sigaev.ru> wrote:
>>
>> Skip full index scan during cleanup of B-tree indexes when possible
>
>
> Thank you for committing this.
>
> It appears that patch contains some redundant variabled. See warnings
> produced
> by gcc-7.
I also see an assertion failure within _bt_getrootheight():
TRAP: FailedAssertion("!(metad->btm_version == 3)", File:
"/home/pg/postgresql/root/build/../source/src/backend/access/nbtree/nbtpage.c",
Line: 619)
--
Peter Geoghegan
^ permalink raw reply [nested|flat] 18+ messages in thread
* Re: pgsql: Skip full index scan during cleanup of B-tree indexes when possi
2018-04-04 16:29 pgsql: Skip full index scan during cleanup of B-tree indexes when possi Teodor Sigaev <teodor@sigaev.ru>
2018-04-04 22:32 ` Re: pgsql: Skip full index scan during cleanup of B-tree indexes when possi Alexander Korotkov <a.korotkov@postgrespro.ru>
2018-04-05 00:00 ` Re: pgsql: Skip full index scan during cleanup of B-tree indexes when possi Peter Geoghegan <pg@bowt.ie>
@ 2018-04-05 00:58 ` Tom Lane <tgl@sss.pgh.pa.us>
2018-04-05 02:12 ` Re: pgsql: Skip full index scan during cleanup of B-tree indexes when possi Michael Paquier <michael@paquier.xyz>
2018-04-05 02:52 ` Re: pgsql: Skip full index scan during cleanup of B-tree indexes when possi Peter Geoghegan <pg@bowt.ie>
0 siblings, 2 replies; 18+ messages in thread
From: Tom Lane @ 2018-04-05 00:58 UTC (permalink / raw)
To: Peter Geoghegan <pg@bowt.ie>; +Cc: Alexander Korotkov <a.korotkov@postgrespro.ru>; Teodor Sigaev <teodor@sigaev.ru>; pgsql-committers <pgsql-committers@lists.postgresql.org>
Peter Geoghegan <pg@bowt.ie> writes:
> I also see an assertion failure within _bt_getrootheight():
> TRAP: FailedAssertion("!(metad->btm_version == 3)", File:
> "/home/pg/postgresql/root/build/../source/src/backend/access/nbtree/nbtpage.c",
> Line: 619)
Hm, buildfarm's not complaining --- what's the test case?
regards, tom lane
^ permalink raw reply [nested|flat] 18+ messages in thread
* Re: pgsql: Skip full index scan during cleanup of B-tree indexes when possi
2018-04-04 16:29 pgsql: Skip full index scan during cleanup of B-tree indexes when possi Teodor Sigaev <teodor@sigaev.ru>
2018-04-04 22:32 ` Re: pgsql: Skip full index scan during cleanup of B-tree indexes when possi Alexander Korotkov <a.korotkov@postgrespro.ru>
2018-04-05 00:00 ` Re: pgsql: Skip full index scan during cleanup of B-tree indexes when possi Peter Geoghegan <pg@bowt.ie>
2018-04-05 00:58 ` Re: pgsql: Skip full index scan during cleanup of B-tree indexes when possi Tom Lane <tgl@sss.pgh.pa.us>
@ 2018-04-05 02:12 ` Michael Paquier <michael@paquier.xyz>
1 sibling, 0 replies; 18+ messages in thread
From: Michael Paquier @ 2018-04-05 02:12 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Peter Geoghegan <pg@bowt.ie>; Alexander Korotkov <a.korotkov@postgrespro.ru>; Teodor Sigaev <teodor@sigaev.ru>; pgsql-committers <pgsql-committers@lists.postgresql.org>
On Wed, Apr 04, 2018 at 08:58:14PM -0400, Tom Lane wrote:
> Peter Geoghegan <pg@bowt.ie> writes:
> > I also see an assertion failure within _bt_getrootheight():
>
> > TRAP: FailedAssertion("!(metad->btm_version == 3)", File:
> > "/home/pg/postgresql/root/build/../source/src/backend/access/nbtree/nbtpage.c",
> > Line: 619)
>
> Hm, buildfarm's not complaining --- what's the test case?
Hm. No problems here either with a56e267 and gcc 7.3. The warnings are
here for sure, and any compiler would complain about those.
--
Michael
Attachments:
signature.asc (application/pgp-signature, 832B) download
^ permalink raw reply [nested|flat] 18+ messages in thread
* Re: pgsql: Skip full index scan during cleanup of B-tree indexes when possi
2018-04-04 16:29 pgsql: Skip full index scan during cleanup of B-tree indexes when possi Teodor Sigaev <teodor@sigaev.ru>
2018-04-04 22:32 ` Re: pgsql: Skip full index scan during cleanup of B-tree indexes when possi Alexander Korotkov <a.korotkov@postgrespro.ru>
2018-04-05 00:00 ` Re: pgsql: Skip full index scan during cleanup of B-tree indexes when possi Peter Geoghegan <pg@bowt.ie>
2018-04-05 00:58 ` Re: pgsql: Skip full index scan during cleanup of B-tree indexes when possi Tom Lane <tgl@sss.pgh.pa.us>
@ 2018-04-05 02:52 ` Peter Geoghegan <pg@bowt.ie>
2018-04-05 03:28 ` Re: pgsql: Skip full index scan during cleanup of B-tree indexes when possi Tom Lane <tgl@sss.pgh.pa.us>
1 sibling, 1 reply; 18+ messages in thread
From: Peter Geoghegan @ 2018-04-05 02:52 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Alexander Korotkov <a.korotkov@postgrespro.ru>; Teodor Sigaev <teodor@sigaev.ru>; pgsql-committers <pgsql-committers@lists.postgresql.org>
On Wed, Apr 4, 2018 at 5:58 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> TRAP: FailedAssertion("!(metad->btm_version == 3)", File:
>> "/home/pg/postgresql/root/build/../source/src/backend/access/nbtree/nbtpage.c",
>> Line: 619)
>
> Hm, buildfarm's not complaining --- what's the test case?
This was discovered while testing/reviewing the latest version of the
INCLUDE covering indexes patch. It now seems to be unrelated.
Sorry for the noise.
--
Peter Geoghegan
^ permalink raw reply [nested|flat] 18+ messages in thread
* Re: pgsql: Skip full index scan during cleanup of B-tree indexes when possi
2018-04-04 16:29 pgsql: Skip full index scan during cleanup of B-tree indexes when possi Teodor Sigaev <teodor@sigaev.ru>
2018-04-04 22:32 ` Re: pgsql: Skip full index scan during cleanup of B-tree indexes when possi Alexander Korotkov <a.korotkov@postgrespro.ru>
2018-04-05 00:00 ` Re: pgsql: Skip full index scan during cleanup of B-tree indexes when possi Peter Geoghegan <pg@bowt.ie>
2018-04-05 00:58 ` Re: pgsql: Skip full index scan during cleanup of B-tree indexes when possi Tom Lane <tgl@sss.pgh.pa.us>
2018-04-05 02:52 ` Re: pgsql: Skip full index scan during cleanup of B-tree indexes when possi Peter Geoghegan <pg@bowt.ie>
@ 2018-04-05 03:28 ` Tom Lane <tgl@sss.pgh.pa.us>
2018-04-05 03:35 ` Re: pgsql: Skip full index scan during cleanup of B-tree indexes when possi Peter Geoghegan <pg@bowt.ie>
2018-04-05 11:26 ` Re: pgsql: Skip full index scan during cleanup of B-tree indexes when possi Alexander Korotkov <a.korotkov@postgrespro.ru>
0 siblings, 2 replies; 18+ messages in thread
From: Tom Lane @ 2018-04-05 03:28 UTC (permalink / raw)
To: Peter Geoghegan <pg@bowt.ie>; +Cc: Alexander Korotkov <a.korotkov@postgrespro.ru>; Teodor Sigaev <teodor@sigaev.ru>; pgsql-committers <pgsql-committers@lists.postgresql.org>
Peter Geoghegan <pg@bowt.ie> writes:
>>> TRAP: FailedAssertion("!(metad->btm_version == 3)", File:
>>> "/home/pg/postgresql/root/build/../source/src/backend/access/nbtree/nbtpage.c",
>>> Line: 619)
>> Hm, buildfarm's not complaining --- what's the test case?
> This was discovered while testing/reviewing the latest version of the
> INCLUDE covering indexes patch. It now seems to be unrelated.
Oh, wait ... I wonder if you saw that because you were running a new
backend without having re-initdb'd? Once you had re-initdb'd, then
of course there would be no old-format btree indexes anywhere. But
if you hadn't, then anyplace that was not prepared to cope with the
old header format would complain about pre-existing indexes.
In short, this sounds like a place that did not get the memo about
how to cope with un-upgraded indexes.
regards, tom lane
^ permalink raw reply [nested|flat] 18+ messages in thread
* Re: pgsql: Skip full index scan during cleanup of B-tree indexes when possi
2018-04-04 16:29 pgsql: Skip full index scan during cleanup of B-tree indexes when possi Teodor Sigaev <teodor@sigaev.ru>
2018-04-04 22:32 ` Re: pgsql: Skip full index scan during cleanup of B-tree indexes when possi Alexander Korotkov <a.korotkov@postgrespro.ru>
2018-04-05 00:00 ` Re: pgsql: Skip full index scan during cleanup of B-tree indexes when possi Peter Geoghegan <pg@bowt.ie>
2018-04-05 00:58 ` Re: pgsql: Skip full index scan during cleanup of B-tree indexes when possi Tom Lane <tgl@sss.pgh.pa.us>
2018-04-05 02:52 ` Re: pgsql: Skip full index scan during cleanup of B-tree indexes when possi Peter Geoghegan <pg@bowt.ie>
2018-04-05 03:28 ` Re: pgsql: Skip full index scan during cleanup of B-tree indexes when possi Tom Lane <tgl@sss.pgh.pa.us>
@ 2018-04-05 03:35 ` Peter Geoghegan <pg@bowt.ie>
1 sibling, 0 replies; 18+ messages in thread
From: Peter Geoghegan @ 2018-04-05 03:35 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Alexander Korotkov <a.korotkov@postgrespro.ru>; Teodor Sigaev <teodor@sigaev.ru>; pgsql-committers <pgsql-committers@lists.postgresql.org>
On Wed, Apr 4, 2018 at 8:28 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> This was discovered while testing/reviewing the latest version of the
>> INCLUDE covering indexes patch. It now seems to be unrelated.
>
> Oh, wait ... I wonder if you saw that because you were running a new
> backend without having re-initdb'd?
Yes. That's what happened.
> Once you had re-initdb'd, then
> of course there would be no old-format btree indexes anywhere. But
> if you hadn't, then anyplace that was not prepared to cope with the
> old header format would complain about pre-existing indexes.
>
> In short, this sounds like a place that did not get the memo about
> how to cope with un-upgraded indexes.
Sounds plausible.
--
Peter Geoghegan
^ permalink raw reply [nested|flat] 18+ messages in thread
* Re: pgsql: Skip full index scan during cleanup of B-tree indexes when possi
2018-04-04 16:29 pgsql: Skip full index scan during cleanup of B-tree indexes when possi Teodor Sigaev <teodor@sigaev.ru>
2018-04-04 22:32 ` Re: pgsql: Skip full index scan during cleanup of B-tree indexes when possi Alexander Korotkov <a.korotkov@postgrespro.ru>
2018-04-05 00:00 ` Re: pgsql: Skip full index scan during cleanup of B-tree indexes when possi Peter Geoghegan <pg@bowt.ie>
2018-04-05 00:58 ` Re: pgsql: Skip full index scan during cleanup of B-tree indexes when possi Tom Lane <tgl@sss.pgh.pa.us>
2018-04-05 02:52 ` Re: pgsql: Skip full index scan during cleanup of B-tree indexes when possi Peter Geoghegan <pg@bowt.ie>
2018-04-05 03:28 ` Re: pgsql: Skip full index scan during cleanup of B-tree indexes when possi Tom Lane <tgl@sss.pgh.pa.us>
@ 2018-04-05 11:26 ` Alexander Korotkov <a.korotkov@postgrespro.ru>
2018-04-05 12:24 ` Re: pgsql: Skip full index scan during cleanup of B-tree indexes when possi Alexander Korotkov <a.korotkov@postgrespro.ru>
1 sibling, 1 reply; 18+ messages in thread
From: Alexander Korotkov @ 2018-04-05 11:26 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Peter Geoghegan <pg@bowt.ie>; Teodor Sigaev <teodor@sigaev.ru>; pgsql-committers <pgsql-committers@lists.postgresql.org>
On Thu, Apr 5, 2018 at 6:28 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Peter Geoghegan <pg@bowt.ie> writes:
> >>> TRAP: FailedAssertion("!(metad->btm_version == 3)", File:
> >>> "/home/pg/postgresql/root/build/../source/src/backend/
> access/nbtree/nbtpage.c",
> >>> Line: 619)
>
> >> Hm, buildfarm's not complaining --- what's the test case?
>
> > This was discovered while testing/reviewing the latest version of the
> > INCLUDE covering indexes patch. It now seems to be unrelated.
>
> Oh, wait ... I wonder if you saw that because you were running a new
> backend without having re-initdb'd? Once you had re-initdb'd, then
> of course there would be no old-format btree indexes anywhere. But
> if you hadn't, then anyplace that was not prepared to cope with the
> old header format would complain about pre-existing indexes.
>
> In short, this sounds like a place that did not get the memo about
> how to cope with un-upgraded indexes.
>
That's an issue, because meta-page should be upgraded "on the fly".
That was tested, but perhaps without assertions. I'll investigate more on
this an propose a fix.
------
Alexander Korotkov
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company
^ permalink raw reply [nested|flat] 18+ messages in thread
* Re: pgsql: Skip full index scan during cleanup of B-tree indexes when possi
2018-04-04 16:29 pgsql: Skip full index scan during cleanup of B-tree indexes when possi Teodor Sigaev <teodor@sigaev.ru>
2018-04-04 22:32 ` Re: pgsql: Skip full index scan during cleanup of B-tree indexes when possi Alexander Korotkov <a.korotkov@postgrespro.ru>
2018-04-05 00:00 ` Re: pgsql: Skip full index scan during cleanup of B-tree indexes when possi Peter Geoghegan <pg@bowt.ie>
2018-04-05 00:58 ` Re: pgsql: Skip full index scan during cleanup of B-tree indexes when possi Tom Lane <tgl@sss.pgh.pa.us>
2018-04-05 02:52 ` Re: pgsql: Skip full index scan during cleanup of B-tree indexes when possi Peter Geoghegan <pg@bowt.ie>
2018-04-05 03:28 ` Re: pgsql: Skip full index scan during cleanup of B-tree indexes when possi Tom Lane <tgl@sss.pgh.pa.us>
2018-04-05 11:26 ` Re: pgsql: Skip full index scan during cleanup of B-tree indexes when possi Alexander Korotkov <a.korotkov@postgrespro.ru>
@ 2018-04-05 12:24 ` Alexander Korotkov <a.korotkov@postgrespro.ru>
2018-04-05 12:29 ` Re: pgsql: Skip full index scan during cleanup of B-tree indexes when possi Alexander Korotkov <a.korotkov@postgrespro.ru>
0 siblings, 1 reply; 18+ messages in thread
From: Alexander Korotkov @ 2018-04-05 12:24 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Peter Geoghegan <pg@bowt.ie>; Teodor Sigaev <teodor@sigaev.ru>; pgsql-committers <pgsql-committers@lists.postgresql.org>
On Thu, Apr 5, 2018 at 2:26 PM, Alexander Korotkov <
a.korotkov@postgrespro.ru> wrote:
> On Thu, Apr 5, 2018 at 6:28 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>
>> Peter Geoghegan <pg@bowt.ie> writes:
>> >>> TRAP: FailedAssertion("!(metad->btm_version == 3)", File:
>> >>> "/home/pg/postgresql/root/build/../source/src/backend/access
>> /nbtree/nbtpage.c",
>> >>> Line: 619)
>>
>> >> Hm, buildfarm's not complaining --- what's the test case?
>>
>> > This was discovered while testing/reviewing the latest version of the
>> > INCLUDE covering indexes patch. It now seems to be unrelated.
>>
>> Oh, wait ... I wonder if you saw that because you were running a new
>> backend without having re-initdb'd? Once you had re-initdb'd, then
>> of course there would be no old-format btree indexes anywhere. But
>> if you hadn't, then anyplace that was not prepared to cope with the
>> old header format would complain about pre-existing indexes.
>>
>> In short, this sounds like a place that did not get the memo about
>> how to cope with un-upgraded indexes.
>>
>
> That's an issue, because meta-page should be upgraded "on the fly".
> That was tested, but perhaps without assertions. I'll investigate more on
> this an propose a fix.
>
So, "Assert(metad->btm_version == BTREE_VERSION)" was failed, because
metadata was copied from meta page to rel->rd_amcache "as is" with
metad->btm_version == BTREE_MIN_VERSION.
Without assert everything works fine, because extended metadata fields are
never used from rel->rd_amcache. So my first intention was to relax this
assert to Assert(metad->btm_version >= BTREE_MIN_VERSION && metad->btm_version
<= BTREE_VERSION).
But then I still have concern that we copy metadata beyond pd_lower
when metapage is in old format.
memcpy(rel->rd_amcache, metad, sizeof(BTMetaPageData));
This is why I decided to write separate function to handle caching of
metadata,
which takes care about filling unavailable fields of metadata with default
values.
I also made same fix for pageinspect. Patch is attached.
------
Alexander Korotkov
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company
Attachments:
btcleanup-metapage-fix.patch (application/octet-stream, 3.5K) download
diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 5133653791..d3d20daabe 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -555,8 +555,21 @@ bt_metap(PG_FUNCTION_ARGS)
values[j++] = psprintf("%d", metad->btm_level);
values[j++] = psprintf("%d", metad->btm_fastroot);
values[j++] = psprintf("%d", metad->btm_fastlevel);
- values[j++] = psprintf("%u", metad->btm_oldest_btpo_xact);
- values[j++] = psprintf("%lf", metad->btm_last_cleanup_num_heap_tuples);
+
+ /*
+ * Get values of extended metadata if available, use defaul values
+ * otherwise.
+ */
+ if (metad->btm_version == BTREE_VERSION)
+ {
+ values[j++] = psprintf("%u", metad->btm_oldest_btpo_xact);
+ values[j++] = psprintf("%lf", metad->btm_last_cleanup_num_heap_tuples);
+ }
+ else
+ {
+ values[j++] = "0";
+ values[j++] = "-1";
+ }
tuple = BuildTupleFromCStrings(TupleDescGetAttInMetadata(tupleDesc),
values);
diff --git a/src/backend/access/nbtree/nbtpage.c b/src/backend/access/nbtree/nbtpage.c
index c98603bbf8..019fe48cb6 100644
--- a/src/backend/access/nbtree/nbtpage.c
+++ b/src/backend/access/nbtree/nbtpage.c
@@ -33,6 +33,7 @@
#include "storage/predicate.h"
#include "utils/snapmgr.h"
+static void _bt_cachemetadata(Relation rel, BTMetaPageData *metad);
static bool _bt_mark_page_halfdead(Relation rel, Buffer buf, BTStack stack);
static bool _bt_unlink_halfdead_page(Relation rel, Buffer leafbuf,
bool *rightsib_empty);
@@ -105,6 +106,44 @@ _bt_upgrademetapage(Page page)
((char *) metad + sizeof(BTMetaPageData)) - (char *) page;
}
+/*
+ * Cache metadata from meta page to rel->rd_amcache.
+ */
+static void
+_bt_cachemetadata(Relation rel, BTMetaPageData *metad)
+{
+ /* We assume rel->rd_amcache was already freed by caller */
+ Assert(rel->rd_amcache == NULL);
+ rel->rd_amcache = MemoryContextAlloc(rel->rd_indexcxt,
+ sizeof(BTMetaPageData));
+
+ /*
+ * Meta page should be of supported version (should be already checked by
+ * caller).
+ */
+ Assert(metad->btm_version >= BTREE_MIN_VERSION &&
+ metad->btm_version <= BTREE_VERSION);
+
+ if (metad->btm_version == BTREE_VERSION)
+ {
+ /* Last version of meta-data, no need to upgrade */
+ memcpy(rel->rd_amcache, metad, sizeof(BTMetaPageData));
+ }
+ else
+ {
+ BTMetaPageData *cached_metad = (BTMetaPageData *) rel->rd_amcache;
+
+ /*
+ * Upgrade meta-data: copy available information from meta-page and
+ * fill new fields with default values.
+ */
+ memcpy(rel->rd_amcache, metad, offsetof(BTMetaPageData, btm_oldest_btpo_xact));
+ cached_metad->btm_version = BTREE_VERSION;
+ cached_metad->btm_oldest_btpo_xact = InvalidTransactionId;
+ cached_metad->btm_last_cleanup_num_heap_tuples = -1.0;
+ }
+}
+
/*
* _bt_update_meta_cleanup_info() -- Update cleanup-related information in
* the metapage.
@@ -403,9 +442,7 @@ _bt_getroot(Relation rel, int access)
/*
* Cache the metapage data for next time
*/
- rel->rd_amcache = MemoryContextAlloc(rel->rd_indexcxt,
- sizeof(BTMetaPageData));
- memcpy(rel->rd_amcache, metad, sizeof(BTMetaPageData));
+ _bt_cachemetadata(rel, metad);
/*
* We are done with the metapage; arrange to release it via first
@@ -604,9 +641,7 @@ _bt_getrootheight(Relation rel)
/*
* Cache the metapage data for next time
*/
- rel->rd_amcache = MemoryContextAlloc(rel->rd_indexcxt,
- sizeof(BTMetaPageData));
- memcpy(rel->rd_amcache, metad, sizeof(BTMetaPageData));
+ _bt_cachemetadata(rel, metad);
_bt_relbuf(rel, metabuf);
}
^ permalink raw reply [nested|flat] 18+ messages in thread
* Re: pgsql: Skip full index scan during cleanup of B-tree indexes when possi
2018-04-04 16:29 pgsql: Skip full index scan during cleanup of B-tree indexes when possi Teodor Sigaev <teodor@sigaev.ru>
2018-04-04 22:32 ` Re: pgsql: Skip full index scan during cleanup of B-tree indexes when possi Alexander Korotkov <a.korotkov@postgrespro.ru>
2018-04-05 00:00 ` Re: pgsql: Skip full index scan during cleanup of B-tree indexes when possi Peter Geoghegan <pg@bowt.ie>
2018-04-05 00:58 ` Re: pgsql: Skip full index scan during cleanup of B-tree indexes when possi Tom Lane <tgl@sss.pgh.pa.us>
2018-04-05 02:52 ` Re: pgsql: Skip full index scan during cleanup of B-tree indexes when possi Peter Geoghegan <pg@bowt.ie>
2018-04-05 03:28 ` Re: pgsql: Skip full index scan during cleanup of B-tree indexes when possi Tom Lane <tgl@sss.pgh.pa.us>
2018-04-05 11:26 ` Re: pgsql: Skip full index scan during cleanup of B-tree indexes when possi Alexander Korotkov <a.korotkov@postgrespro.ru>
2018-04-05 12:24 ` Re: pgsql: Skip full index scan during cleanup of B-tree indexes when possi Alexander Korotkov <a.korotkov@postgrespro.ru>
@ 2018-04-05 12:29 ` Alexander Korotkov <a.korotkov@postgrespro.ru>
0 siblings, 0 replies; 18+ messages in thread
From: Alexander Korotkov @ 2018-04-05 12:29 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Peter Geoghegan <pg@bowt.ie>; Teodor Sigaev <teodor@sigaev.ru>; pgsql-committers <pgsql-committers@lists.postgresql.org>
On Thu, Apr 5, 2018 at 3:24 PM, Alexander Korotkov <
a.korotkov@postgrespro.ru> wrote:
> On Thu, Apr 5, 2018 at 2:26 PM, Alexander Korotkov <
> a.korotkov@postgrespro.ru> wrote:
>
>> On Thu, Apr 5, 2018 at 6:28 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>>
>>> Peter Geoghegan <pg@bowt.ie> writes:
>>> >>> TRAP: FailedAssertion("!(metad->btm_version == 3)", File:
>>> >>> "/home/pg/postgresql/root/build/../source/src/backend/access
>>> /nbtree/nbtpage.c",
>>> >>> Line: 619)
>>>
>>> >> Hm, buildfarm's not complaining --- what's the test case?
>>>
>>> > This was discovered while testing/reviewing the latest version of the
>>> > INCLUDE covering indexes patch. It now seems to be unrelated.
>>>
>>> Oh, wait ... I wonder if you saw that because you were running a new
>>> backend without having re-initdb'd? Once you had re-initdb'd, then
>>> of course there would be no old-format btree indexes anywhere. But
>>> if you hadn't, then anyplace that was not prepared to cope with the
>>> old header format would complain about pre-existing indexes.
>>>
>>> In short, this sounds like a place that did not get the memo about
>>> how to cope with un-upgraded indexes.
>>>
>>
>> That's an issue, because meta-page should be upgraded "on the fly".
>> That was tested, but perhaps without assertions. I'll investigate more on
>> this an propose a fix.
>>
>
> So, "Assert(metad->btm_version == BTREE_VERSION)" was failed, because
> metadata was copied from meta page to rel->rd_amcache "as is" with
> metad->btm_version == BTREE_MIN_VERSION.
>
> Without assert everything works fine, because extended metadata fields are
> never used from rel->rd_amcache. So my first intention was to relax this
> assert to Assert(metad->btm_version >= BTREE_MIN_VERSION && metad->btm_version
> <= BTREE_VERSION).
> But then I still have concern that we copy metadata beyond pd_lower
> when metapage is in old format.
>
> memcpy(rel->rd_amcache, metad, sizeof(BTMetaPageData));
>
> This is why I decided to write separate function to handle caching of
> metadata,
> which takes care about filling unavailable fields of metadata with default
> values.
> I also made same fix for pageinspect. Patch is attached.
>
I forgot to note, that I've tested this patch in following way. I did
initdb and
created some tables and indexes on eac93e20af. And then used the
same cluster on patched master including index scans, some
inserts/updates/deletes,
bt_metap(), vacuum and so on. Everything worked fine.
Sorry, that I didn't test that enough before.
------
Alexander Korotkov
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company
^ permalink raw reply [nested|flat] 18+ messages in thread
* Re: pgsql: Skip full index scan during cleanup of B-tree indexes when possi
2018-04-04 16:29 pgsql: Skip full index scan during cleanup of B-tree indexes when possi Teodor Sigaev <teodor@sigaev.ru>
2018-04-04 22:32 ` Re: pgsql: Skip full index scan during cleanup of B-tree indexes when possi Alexander Korotkov <a.korotkov@postgrespro.ru>
@ 2018-04-05 11:16 ` Alexander Korotkov <a.korotkov@postgrespro.ru>
1 sibling, 0 replies; 18+ messages in thread
From: Alexander Korotkov @ 2018-04-05 11:16 UTC (permalink / raw)
To: Teodor Sigaev <teodor@sigaev.ru>; +Cc: pgsql-committers@lists.postgresql.org
On Thu, Apr 5, 2018 at 1:32 AM, Alexander Korotkov <
a.korotkov@postgrespro.ru> wrote:
> On Wed, Apr 4, 2018 at 7:29 PM, Teodor Sigaev <teodor@sigaev.ru> wrote:
>
>> Skip full index scan during cleanup of B-tree indexes when possible
>>
>
> Thank you for committing this.
>
> It appears that patch contains some redundant variabled. See warnings
> produced
> by gcc-7.
>
> nbtpage.c: In function '_bt_update_meta_cleanup_info':
> nbtpage.c:121:15: warning: variable 'metaopaque' set but not used
> [-Wunused-but-set-variable]
> BTPageOpaque metaopaque;
> ^~~~~~~~~~
> nbtree.c: In function '_bt_vacuum_needs_cleanup':
> nbtree.c:790:15: warning: variable 'metaopaque' set but not used
> [-Wunused-but-set-variable]
> BTPageOpaque metaopaque;
> ^~~~~~~~~~
>
> Attached patch fixes this.
>
Teodor already committed [1] better patch [2] from Kyotaro Horiguchi. This
question is closed.
1.
https://www.postgresql.org/message-id/E1f41xX-00029Y-EO%40gemulon.postgresql.org
2. https://www.postgresql.org/message-id/20180405.181730.
125855581.horiguchi.kyotaro%40lab.ntt.co.jp
------
Alexander Korotkov
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company
^ permalink raw reply [nested|flat] 18+ messages in thread
* Re: pgsql: Skip full index scan during cleanup of B-tree indexes when possi
2018-04-04 16:29 pgsql: Skip full index scan during cleanup of B-tree indexes when possi Teodor Sigaev <teodor@sigaev.ru>
@ 2018-04-18 18:12 ` Fujii Masao <masao.fujii@gmail.com>
2018-04-18 18:21 ` Re: pgsql: Skip full index scan during cleanup of B-tree indexes when possi Peter Geoghegan <pg@bowt.ie>
1 sibling, 1 reply; 18+ messages in thread
From: Fujii Masao @ 2018-04-18 18:12 UTC (permalink / raw)
To: Teodor Sigaev <teodor@sigaev.ru>; +Cc: pgsql-committers@lists.postgresql.org
On Thu, Apr 5, 2018 at 1:29 AM, Teodor Sigaev <teodor@sigaev.ru> wrote:
> Skip full index scan during cleanup of B-tree indexes when possible
This commit added XLOG_BTREE_META_CLEANUP, so btree_desc() and
btree_identify() should be updated so that they handle XLOG_BTREE_META_CLEANUP.
But ISTM that you forgot doing that.
Regards,
--
Fujii Masao
^ permalink raw reply [nested|flat] 18+ messages in thread
* Re: pgsql: Skip full index scan during cleanup of B-tree indexes when possi
2018-04-04 16:29 pgsql: Skip full index scan during cleanup of B-tree indexes when possi Teodor Sigaev <teodor@sigaev.ru>
2018-04-18 18:12 ` Re: pgsql: Skip full index scan during cleanup of B-tree indexes when possi Fujii Masao <masao.fujii@gmail.com>
@ 2018-04-18 18:21 ` Peter Geoghegan <pg@bowt.ie>
2018-04-18 22:03 ` Re: pgsql: Skip full index scan during cleanup of B-tree indexes when possi Alexander Korotkov <a.korotkov@postgrespro.ru>
0 siblings, 1 reply; 18+ messages in thread
From: Peter Geoghegan @ 2018-04-18 18:21 UTC (permalink / raw)
To: Fujii Masao <masao.fujii@gmail.com>; +Cc: Teodor Sigaev <teodor@sigaev.ru>; pgsql-committers <pgsql-committers@lists.postgresql.org>
On Wed, Apr 18, 2018 at 11:12 AM, Fujii Masao <masao.fujii@gmail.com> wrote:
> On Thu, Apr 5, 2018 at 1:29 AM, Teodor Sigaev <teodor@sigaev.ru> wrote:
>> Skip full index scan during cleanup of B-tree indexes when possible
>
> This commit added XLOG_BTREE_META_CLEANUP, so btree_desc() and
> btree_identify() should be updated so that they handle XLOG_BTREE_META_CLEANUP.
> But ISTM that you forgot doing that.
Another thing that I noticed is that the metapage stores
btm_last_cleanup_num_heap_tuples as a float4, even though
xl_btree_metadata stores it as a double. I suggest that both places
store it as float8, to be consistent. (It should not be double because
we always avoid using anything other types with explicit typedef'd
widths in WAL records.)
--
Peter Geoghegan
^ permalink raw reply [nested|flat] 18+ messages in thread
* Re: pgsql: Skip full index scan during cleanup of B-tree indexes when possi
2018-04-04 16:29 pgsql: Skip full index scan during cleanup of B-tree indexes when possi Teodor Sigaev <teodor@sigaev.ru>
2018-04-18 18:12 ` Re: pgsql: Skip full index scan during cleanup of B-tree indexes when possi Fujii Masao <masao.fujii@gmail.com>
2018-04-18 18:21 ` Re: pgsql: Skip full index scan during cleanup of B-tree indexes when possi Peter Geoghegan <pg@bowt.ie>
@ 2018-04-18 22:03 ` Alexander Korotkov <a.korotkov@postgrespro.ru>
2018-04-19 06:19 ` Re: pgsql: Skip full index scan during cleanup of B-tree indexes when possi Teodor Sigaev <teodor@sigaev.ru>
2018-04-19 08:29 ` Re: pgsql: Skip full index scan during cleanup of B-tree indexes when possi Teodor Sigaev <teodor@sigaev.ru>
0 siblings, 2 replies; 18+ messages in thread
From: Alexander Korotkov @ 2018-04-18 22:03 UTC (permalink / raw)
To: Peter Geoghegan <pg@bowt.ie>; +Cc: Fujii Masao <masao.fujii@gmail.com>; Teodor Sigaev <teodor@sigaev.ru>; pgsql-committers <pgsql-committers@lists.postgresql.org>
On Wed, Apr 18, 2018 at 9:21 PM, Peter Geoghegan <pg@bowt.ie> wrote:
> On Wed, Apr 18, 2018 at 11:12 AM, Fujii Masao <masao.fujii@gmail.com>
> wrote:
> > On Thu, Apr 5, 2018 at 1:29 AM, Teodor Sigaev <teodor@sigaev.ru> wrote:
> >> Skip full index scan during cleanup of B-tree indexes when possible
> >
> > This commit added XLOG_BTREE_META_CLEANUP, so btree_desc() and
> > btree_identify() should be updated so that they handle
> XLOG_BTREE_META_CLEANUP.
> > But ISTM that you forgot doing that.
>
Thank you for notice. See attached
bt-vacuum-cleanup-wal-record-desc-identify.patch fixing that.
Another thing that I noticed is that the metapage stores
> btm_last_cleanup_num_heap_tuples as a float4, even though
> xl_btree_metadata stores it as a double. I suggest that both places
> store it as float8, to be consistent. (It should not be double because
> we always avoid using anything other types with explicit typedef'd
> widths in WAL records.)
Good catch, thank you! I also agree that both these fields should be of
float8 type.
Please, find attached bt-vacuum-cleanup-float8-num-heap-tuples.patch fixing
that.
------
Alexander Korotkov
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company
Attachments: download all (2 files, .tar.gz)
bt-vacuum-cleanup-wal-record-desc-identify.patch (application/octet-stream, 1.2K) download
commit f0370b2293f3a7f3ce59b6164ae96798ba4bbe0d
Author: Alexander Korotkov <a.korotkov@postgrespro.ru>
Date: Thu Apr 19 00:56:37 2018 +0300
Handle XLOG_BTREE_META_CLEANUP in btree_desc() and btree_identify()
New WAL record XLOG_BTREE_META_CLEANUP introduced in 857f9c36 has no handling
in btree_desc() and btree_identify(). This patch implements corresponding
handling.
diff --git a/src/backend/access/rmgrdesc/nbtdesc.c b/src/backend/access/rmgrdesc/nbtdesc.c
index 0b996ea13a..384ac07289 100644
--- a/src/backend/access/rmgrdesc/nbtdesc.c
+++ b/src/backend/access/rmgrdesc/nbtdesc.c
@@ -96,6 +96,15 @@ btree_desc(StringInfo buf, XLogReaderState *record)
xlrec->node.relNode, xlrec->latestRemovedXid);
break;
}
+ case XLOG_BTREE_META_CLEANUP:
+ {
+ xl_btree_metadata *xlrec = (xl_btree_metadata *) rec;
+
+ appendStringInfo(buf, "oldest_btpo_xact %u; last_cleanup_num_heap_tuples: %lf",
+ xlrec->oldest_btpo_xact,
+ xlrec->last_cleanup_num_heap_tuples);
+ break;
+ }
}
}
@@ -148,6 +157,9 @@ btree_identify(uint8 info)
case XLOG_BTREE_REUSE_PAGE:
id = "REUSE_PAGE";
break;
+ case XLOG_BTREE_META_CLEANUP:
+ id = "META CLEANUP";
+ break;
}
return id;
bt-vacuum-cleanup-float8-num-heap-tuples.patch (application/octet-stream, 1.7K) download
commit c0a08cfadc472dbf674304ab5de94bd0946ca473
Author: Alexander Korotkov <a.korotkov@postgrespro.ru>
Date: Thu Apr 19 00:44:44 2018 +0300
Fix datatype for number of heap tuples during last cleanup
It appears that new fields introduced in 857f9c36 have inconsistent datatypes:
BTMetaPageData.btm_last_cleanup_num_heap_tuples is of float4 type,
while xl_btree_metadata.last_cleanup_num_heap_tuples is of double type.
IndexVacuumInfo.num_heap_tuples, which is a source of values for
both former fields is of double type. So, make both those fields in
BTMetaPageData and xl_btree_metadata use float8 type in order to match the
precision of the source. That shouldn't be double type, because we always
use types with explicit width in WAL.
diff --git a/src/include/access/nbtree.h b/src/include/access/nbtree.h
index 36619b220f..342b853b4e 100644
--- a/src/include/access/nbtree.h
+++ b/src/include/access/nbtree.h
@@ -105,7 +105,7 @@ typedef struct BTMetaPageData
/* following fields are available since page version 3 */
TransactionId btm_oldest_btpo_xact; /* oldest btpo_xact among of
* deleted pages */
- float4 btm_last_cleanup_num_heap_tuples; /* number of heap tuples
+ float8 btm_last_cleanup_num_heap_tuples; /* number of heap tuples
* during last cleanup */
} BTMetaPageData;
diff --git a/src/include/access/nbtxlog.h b/src/include/access/nbtxlog.h
index c55b618ff7..819373031c 100644
--- a/src/include/access/nbtxlog.h
+++ b/src/include/access/nbtxlog.h
@@ -52,7 +52,7 @@ typedef struct xl_btree_metadata
BlockNumber fastroot;
uint32 fastlevel;
TransactionId oldest_btpo_xact;
- double last_cleanup_num_heap_tuples;
+ float8 last_cleanup_num_heap_tuples;
} xl_btree_metadata;
/*
^ permalink raw reply [nested|flat] 18+ messages in thread
* Re: pgsql: Skip full index scan during cleanup of B-tree indexes when possi
2018-04-04 16:29 pgsql: Skip full index scan during cleanup of B-tree indexes when possi Teodor Sigaev <teodor@sigaev.ru>
2018-04-18 18:12 ` Re: pgsql: Skip full index scan during cleanup of B-tree indexes when possi Fujii Masao <masao.fujii@gmail.com>
2018-04-18 18:21 ` Re: pgsql: Skip full index scan during cleanup of B-tree indexes when possi Peter Geoghegan <pg@bowt.ie>
2018-04-18 22:03 ` Re: pgsql: Skip full index scan during cleanup of B-tree indexes when possi Alexander Korotkov <a.korotkov@postgrespro.ru>
@ 2018-04-19 06:19 ` Teodor Sigaev <teodor@sigaev.ru>
2018-04-19 07:44 ` Re: pgsql: Skip full index scan during cleanup of B-tree indexes when possi Alexander Korotkov <a.korotkov@postgrespro.ru>
1 sibling, 1 reply; 18+ messages in thread
From: Teodor Sigaev @ 2018-04-19 06:19 UTC (permalink / raw)
To: Alexander Korotkov <a.korotkov@postgrespro.ru>; Peter Geoghegan <pg@bowt.ie>; +Cc: Fujii Masao <masao.fujii@gmail.com>; pgsql-committers <pgsql-committers@lists.postgresql.org>
> Another thing that I noticed is that the metapage stores
> btm_last_cleanup_num_heap_tuples as a float4, even though
> xl_btree_metadata stores it as a double. I suggest that both places
> store it as float8, to be consistent. (It should not be double because
> we always avoid using anything other types with explicit typedef'd
> widths in WAL records.)
>
>
> Good catch, thank you! I also agree that both these fields should be of
> float8 type.
> Please, find attached bt-vacuum-cleanup-float8-num-heap-tuples.patch
> fixing that.
Hm. patch changes on-disk representation of btree meta page. And there
is no support to upgrade meta page since 857f9c36 commit (and should
not, because that versions wasn't relesead), to prevent possible false
positive bug reports I suggest to bump catversion. Objections?
--
Teodor Sigaev E-mail: teodor@sigaev.ru
WWW: http://www.sigaev.ru/
^ permalink raw reply [nested|flat] 18+ messages in thread
* Re: pgsql: Skip full index scan during cleanup of B-tree indexes when possi
2018-04-04 16:29 pgsql: Skip full index scan during cleanup of B-tree indexes when possi Teodor Sigaev <teodor@sigaev.ru>
2018-04-18 18:12 ` Re: pgsql: Skip full index scan during cleanup of B-tree indexes when possi Fujii Masao <masao.fujii@gmail.com>
2018-04-18 18:21 ` Re: pgsql: Skip full index scan during cleanup of B-tree indexes when possi Peter Geoghegan <pg@bowt.ie>
2018-04-18 22:03 ` Re: pgsql: Skip full index scan during cleanup of B-tree indexes when possi Alexander Korotkov <a.korotkov@postgrespro.ru>
2018-04-19 06:19 ` Re: pgsql: Skip full index scan during cleanup of B-tree indexes when possi Teodor Sigaev <teodor@sigaev.ru>
@ 2018-04-19 07:44 ` Alexander Korotkov <a.korotkov@postgrespro.ru>
0 siblings, 0 replies; 18+ messages in thread
From: Alexander Korotkov @ 2018-04-19 07:44 UTC (permalink / raw)
To: Teodor Sigaev <teodor@sigaev.ru>; +Cc: Peter Geoghegan <pg@bowt.ie>; Fujii Masao <masao.fujii@gmail.com>; pgsql-committers <pgsql-committers@lists.postgresql.org>
On Thu, Apr 19, 2018 at 9:19 AM, Teodor Sigaev <teodor@sigaev.ru> wrote:
> Another thing that I noticed is that the metapage stores
>> btm_last_cleanup_num_heap_tuples as a float4, even though
>> xl_btree_metadata stores it as a double. I suggest that both places
>> store it as float8, to be consistent. (It should not be double because
>> we always avoid using anything other types with explicit typedef'd
>> widths in WAL records.)
>>
>>
>> Good catch, thank you! I also agree that both these fields should be of
>> float8 type.
>> Please, find attached bt-vacuum-cleanup-float8-num-heap-tuples.patch
>> fixing that.
>>
>
> Hm. patch changes on-disk representation of btree meta page. And there is
> no support to upgrade meta page since 857f9c36 commit (and should not,
> because that versions wasn't relesead), to prevent possible false positive
> bug reports I suggest to bump catversion. Objections?
I agree, catversion should be bumped for this patch.
------
Alexander Korotkov
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company
^ permalink raw reply [nested|flat] 18+ messages in thread
* Re: pgsql: Skip full index scan during cleanup of B-tree indexes when possi
2018-04-04 16:29 pgsql: Skip full index scan during cleanup of B-tree indexes when possi Teodor Sigaev <teodor@sigaev.ru>
2018-04-18 18:12 ` Re: pgsql: Skip full index scan during cleanup of B-tree indexes when possi Fujii Masao <masao.fujii@gmail.com>
2018-04-18 18:21 ` Re: pgsql: Skip full index scan during cleanup of B-tree indexes when possi Peter Geoghegan <pg@bowt.ie>
2018-04-18 22:03 ` Re: pgsql: Skip full index scan during cleanup of B-tree indexes when possi Alexander Korotkov <a.korotkov@postgrespro.ru>
@ 2018-04-19 08:29 ` Teodor Sigaev <teodor@sigaev.ru>
1 sibling, 0 replies; 18+ messages in thread
From: Teodor Sigaev @ 2018-04-19 08:29 UTC (permalink / raw)
To: Alexander Korotkov <a.korotkov@postgrespro.ru>; Peter Geoghegan <pg@bowt.ie>; +Cc: Fujii Masao <masao.fujii@gmail.com>; pgsql-committers <pgsql-committers@lists.postgresql.org>
Thank you, both patches are pushed.
Alexander Korotkov wrote:
> On Wed, Apr 18, 2018 at 9:21 PM, Peter Geoghegan <pg@bowt.ie
> <mailto:pg@bowt.ie>> wrote:
>
> On Wed, Apr 18, 2018 at 11:12 AM, Fujii Masao <masao.fujii@gmail.com
> <mailto:masao.fujii@gmail.com>> wrote:
> > On Thu, Apr 5, 2018 at 1:29 AM, Teodor Sigaev <teodor@sigaev.ru <mailto:teodor@sigaev.ru>> wrote:
> >> Skip full index scan during cleanup of B-tree indexes when possible
> >
> > This commit added XLOG_BTREE_META_CLEANUP, so btree_desc() and
> > btree_identify() should be updated so that they handle XLOG_BTREE_META_CLEANUP.
> > But ISTM that you forgot doing that.
>
> Thank you for notice. See attached
> bt-vacuum-cleanup-wal-record-desc-identify.patch fixing that.
>
> Another thing that I noticed is that the metapage stores
> btm_last_cleanup_num_heap_tuples as a float4, even though
> xl_btree_metadata stores it as a double. I suggest that both places
> store it as float8, to be consistent. (It should not be double because
> we always avoid using anything other types with explicit typedef'd
> widths in WAL records.)
>
>
> Good catch, thank you! I also agree that both these fields should be of float8
> type.
> Please, find attached bt-vacuum-cleanup-float8-num-heap-tuples.patch fixing that.
>
> ------
> Alexander Korotkov
> Postgres Professional:http://www.postgrespro.com <http://www.postgrespro.com/;
> The Russian Postgres Company
>
--
Teodor Sigaev E-mail: teodor@sigaev.ru
WWW: http://www.sigaev.ru/
^ permalink raw reply [nested|flat] 18+ messages in thread
end of thread, other threads:[~2018-04-19 08:29 UTC | newest]
Thread overview: 18+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-04-04 16:29 pgsql: Skip full index scan during cleanup of B-tree indexes when possi Teodor Sigaev <teodor@sigaev.ru>
2018-04-04 22:32 ` Alexander Korotkov <a.korotkov@postgrespro.ru>
2018-04-05 00:00 ` Peter Geoghegan <pg@bowt.ie>
2018-04-05 00:58 ` Tom Lane <tgl@sss.pgh.pa.us>
2018-04-05 02:12 ` Michael Paquier <michael@paquier.xyz>
2018-04-05 02:52 ` Peter Geoghegan <pg@bowt.ie>
2018-04-05 03:28 ` Tom Lane <tgl@sss.pgh.pa.us>
2018-04-05 03:35 ` Peter Geoghegan <pg@bowt.ie>
2018-04-05 11:26 ` Alexander Korotkov <a.korotkov@postgrespro.ru>
2018-04-05 12:24 ` Alexander Korotkov <a.korotkov@postgrespro.ru>
2018-04-05 12:29 ` Alexander Korotkov <a.korotkov@postgrespro.ru>
2018-04-05 11:16 ` Alexander Korotkov <a.korotkov@postgrespro.ru>
2018-04-18 18:12 ` Fujii Masao <masao.fujii@gmail.com>
2018-04-18 18:21 ` Peter Geoghegan <pg@bowt.ie>
2018-04-18 22:03 ` Alexander Korotkov <a.korotkov@postgrespro.ru>
2018-04-19 06:19 ` Teodor Sigaev <teodor@sigaev.ru>
2018-04-19 07:44 ` Alexander Korotkov <a.korotkov@postgrespro.ru>
2018-04-19 08:29 ` Teodor Sigaev <teodor@sigaev.ru>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox