Services
24×7×365 Technical Support
Migration to PostgreSQL
High Availability Deployment
Database Audit
Remote DBA for PostgreSQL
Products
Postgres Pro Enterprise
Postgres Pro Standard
Cloud Solutions
Postgres Extensions
Resources
Blog
Documentation
Webinars
Videos
Presentations
Community
Events
Training Courses
Books
Demo Database
Mailing List Archives
About
Leadership team
Partners
Customers
In the News
Press Releases
Press Info
Services
24×7×365 Technical Support
Migration to PostgreSQL
High Availability Deployment
Database Audit
Remote DBA for PostgreSQL
Products
Postgres Pro Enterprise
Postgres Pro Standard
Cloud Solutions
Postgres Extensions
Resources
Blog
Documentation
Webinars
Videos
Presentations
Community
Events
Training Courses
Books
Demo Database
Mailing List Archives
About
Leadership team
Partners
Customers
In the News
Press Releases
Press Info
Facebook
Downloads
Home
>
mailing lists
Re: [HACKERS] GUC for cleanup indexes threshold. - Mailing list pgsql-hackers
From
Alexander Korotkov
Subject
Re: [HACKERS] GUC for cleanup indexes threshold.
Date
March 9, 2018
02:43:04
Msg-id
CAPpHfdteaDcBscVxzSViEV4CXLU5==9Ocz81CoFSsNWmv-pZpw@mail.gmail.com
Whole thread
Raw
In response to
Re: [HACKERS] GUC for cleanup indexes threshold.
(Alexander Korotkov <a.korotkov@postgrespro.ru>)
Responses
Re: [HACKERS] GUC for cleanup indexes threshold.
Re: [HACKERS] GUC for cleanup indexes threshold.
List
pgsql-hackers
Tree view
Hi!
I'd like to propose a revised patch based on various ideas upthread.
This patch works as following.
1) B-tree meta page is extended with 2 additional parameters:
* btm_oldest_btpo_xact – oldest btpo_xact among of deleted pages,
* btm_last_cleanup_num_heap_tuples – number of heap tuples during last cleanup scan.
2) These parameters are reset during btbulkdelete() and set during btvacuumcleanup().
3) Index scans during second and subsequent
btvacuumcleanup() happen only if
btm_oldest_btpo_xact is older than RecentGlobalXmin
OR num_heap_tuples >=
btm_last_cleanup_num_heap_tuples(1 + vacuum_cleanup_index_scale_factor).
In other words
btvacuumcleanup() scans the index only if there are recyclable pages,
or index statistics is stalled (inserted more than
vacuum_cleanup_index_scale_factor
since last index statistics collection).
4)
vacuum_cleanup_index_scale_factor can be set either by GUC or reloption.
Default value is 0.1. So, by default cleanup scan is triggered after increasing of
table size by 10%.
5) Since new fields are added to the metapage, BTREE_VERSION is bumped.
In order to support pg_upgrade, read of previous metapage version is supported.
On metapage rewrite, it's upgraded to the new version.
So, since we don't skip scan of recyclable pages, there is no risk of xid wraparound.
Risk of stalled statistics is also small, because
vacuum_cleanup_index_scale_factor
default value is quite low. User can increase
vacuum_cleanup_index_scale_factor
on his own risk and have less load of B-tree cleanup scan bought by more gap in
index statistics.
Some simple benchmark shows the effect.
Before patch.
# insert into t select i from generate_series(1,100000000) i;
# create index t_i_idx on t(i);
# vacuum t;
VACUUM
Time: 15639,822 ms (00:15,640)
# insert into t select i from generate_series(1,1000) i;
INSERT 0 1000
Time: 6,195 ms
# vacuum t;
VACUUM
Time: 1012,794 ms (00:01,013)
# insert into t select i from generate_series(1,1000) i;
INSERT 0 1000
Time: 5,276 ms
# vacuum t;
VACUUM
Time: 1013,254 ms (00:01,013)
After patch.
# insert into t select i from generate_series(1,100000000) i;
# create index t_i_idx on t(i);
# vacuum t;
VACUUM
Time: 15689,450 ms (00:15,689)
# insert into t select i from generate_series(1,1000) i;
INSERT 0 1000
Time: 5,585 ms
# vacuum t;
VACUUM
Time: 50,777 ms
# insert into t select i from generate_series(1,1000) i;
INSERT 0 1000
Time: 5,641 ms
# vacuum t;
VACUUM
Time: 46,997 ms
Thus, vacuum time for append-only table drops from 1000 ms to 50 ms (in about 20X).
------
Alexander Korotkov
Postgres Professional:
http://www.postgrespro.com
The Russian Postgres Company
Attachment
0001-lazy-btree-cleanup-3.patch
pgsql-hackers
by date:
Previous
From:
Tomas Vondra
Date:
09 March 2018, 02:29:35
Subject:
Re: [HACKERS] MERGE SQL Statement for PG11
Next
From:
Michael Paquier
Date:
09 March 2018, 03:09:44
Subject:
Re: using worker_spi as pattern
Есть вопросы? Напишите нам!
Соглашаюсь с условиями обработки персональных данных
I confirm that I have read and accepted PostgresPro’s
Privacy Policy
.
I agree to get Postgres Pro discount offers and other marketing communications.
✖
×
×
Everywhere
Documentation
Mailing list
List:
all lists
pgsql-general
pgsql-hackers
buildfarm-members
pgadmin-hackers
pgadmin-support
pgsql-admin
pgsql-advocacy
pgsql-announce
pgsql-benchmarks
pgsql-bugs
pgsql-chat
pgsql-cluster-hackers
pgsql-committers
pgsql-cygwin
pgsql-docs
pgsql-hackers-pitr
pgsql-hackers-win32
pgsql-interfaces
pgsql-jdbc
pgsql-jobs
pgsql-novice
pgsql-odbc
pgsql-patches
pgsql-performance
pgsql-php
pgsql-pkg-debian
pgsql-pkg-yum
pgsql-ports
pgsql-rrreviewers
pgsql-ru-general
pgsql-sql
pgsql-students
pgsql-testers
pgsql-translators
pgsql-www
psycopg
Period
anytime
within last day
within last week
within last month
within last 6 months
within last year
Sort by
date
reverse date
rank
Services
24×7×365 Technical Support
Migration to PostgreSQL
High Availability Deployment
Database Audit
Remote DBA for PostgreSQL
Products
Postgres Pro Enterprise
Postgres Pro Standard
Cloud Solutions
Postgres Extensions
Resources
Blog
Documentation
Webinars
Videos
Presentations
Community
Events
Training Courses
Books
Demo Database
Mailing List Archives
About
Leadership team
Partners
Customers
In the News
Press Releases
Press Info
By continuing to browse this website, you agree to the use of cookies. Go to
Privacy Policy
.
I accept cookies