Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Gpdb
提交
ed8969b1
G
Gpdb
项目概览
Greenplum
/
Gpdb
通知
7
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
Gpdb
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
ed8969b1
编写于
9月 04, 2006
作者:
B
Bruce Momjian
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Trivial patch to double vacuum speed on tables with no indexes (prevent
second scan of table). Gregory Stark
上级
c66939c4
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
33 addition
and
12 deletion
+33
-12
src/backend/commands/vacuumlazy.c
src/backend/commands/vacuumlazy.c
+33
-12
未找到文件。
src/backend/commands/vacuumlazy.c
浏览文件 @
ed8969b1
...
@@ -16,6 +16,10 @@
...
@@ -16,6 +16,10 @@
* perform a pass of index cleanup and page compaction, then resume the heap
* perform a pass of index cleanup and page compaction, then resume the heap
* scan with an empty TID array.
* scan with an empty TID array.
*
*
* As a special exception if we're processing a table with no indexes we can
* vacuum each page as we go so we don't need to allocate more space than
* enough to hold as many heap tuples fit on one page.
*
* We can limit the storage for page free space to MaxFSMPages entries,
* We can limit the storage for page free space to MaxFSMPages entries,
* since that's the most the free space map will be willing to remember
* since that's the most the free space map will be willing to remember
* anyway. If the relation has fewer than that many pages with free space,
* anyway. If the relation has fewer than that many pages with free space,
...
@@ -31,7 +35,7 @@
...
@@ -31,7 +35,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/vacuumlazy.c,v 1.7
6 2006/07/31 20:09:00 tgl
Exp $
* $PostgreSQL: pgsql/src/backend/commands/vacuumlazy.c,v 1.7
7 2006/09/04 21:40:23 momjian
Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -106,7 +110,7 @@ static void lazy_truncate_heap(Relation onerel, LVRelStats *vacrelstats,
...
@@ -106,7 +110,7 @@ static void lazy_truncate_heap(Relation onerel, LVRelStats *vacrelstats,
TransactionId
OldestXmin
);
TransactionId
OldestXmin
);
static
BlockNumber
count_nondeletable_pages
(
Relation
onerel
,
static
BlockNumber
count_nondeletable_pages
(
Relation
onerel
,
LVRelStats
*
vacrelstats
,
TransactionId
OldestXmin
);
LVRelStats
*
vacrelstats
,
TransactionId
OldestXmin
);
static
void
lazy_space_alloc
(
LVRelStats
*
vacrelstats
,
BlockNumber
relblocks
);
static
void
lazy_space_alloc
(
LVRelStats
*
vacrelstats
,
BlockNumber
relblocks
,
unsigned
nindexes
);
static
void
lazy_record_dead_tuple
(
LVRelStats
*
vacrelstats
,
static
void
lazy_record_dead_tuple
(
LVRelStats
*
vacrelstats
,
ItemPointer
itemptr
);
ItemPointer
itemptr
);
static
void
lazy_record_free_space
(
LVRelStats
*
vacrelstats
,
static
void
lazy_record_free_space
(
LVRelStats
*
vacrelstats
,
...
@@ -206,7 +210,8 @@ lazy_vacuum_rel(Relation onerel, VacuumStmt *vacstmt)
...
@@ -206,7 +210,8 @@ lazy_vacuum_rel(Relation onerel, VacuumStmt *vacstmt)
* This routine sets commit status bits, builds lists of dead tuples
* This routine sets commit status bits, builds lists of dead tuples
* and pages with free space, and calculates statistics on the number
* and pages with free space, and calculates statistics on the number
* of live tuples in the heap. When done, or when we run low on space
* of live tuples in the heap. When done, or when we run low on space
* for dead-tuple TIDs, invoke vacuuming of indexes and heap.
* for dead-tuple TIDs, or after every page if the table has no indexes
* invoke vacuuming of indexes and heap.
*
*
* It also updates the minimum Xid found anywhere on the table in
* It also updates the minimum Xid found anywhere on the table in
* vacrelstats->minxid, for later storing it in pg_class.relminxid.
* vacrelstats->minxid, for later storing it in pg_class.relminxid.
...
@@ -247,7 +252,7 @@ lazy_scan_heap(Relation onerel, LVRelStats *vacrelstats,
...
@@ -247,7 +252,7 @@ lazy_scan_heap(Relation onerel, LVRelStats *vacrelstats,
vacrelstats
->
rel_pages
=
nblocks
;
vacrelstats
->
rel_pages
=
nblocks
;
vacrelstats
->
nonempty_pages
=
0
;
vacrelstats
->
nonempty_pages
=
0
;
lazy_space_alloc
(
vacrelstats
,
nblocks
);
lazy_space_alloc
(
vacrelstats
,
nblocks
,
nindexes
);
for
(
blkno
=
0
;
blkno
<
nblocks
;
blkno
++
)
for
(
blkno
=
0
;
blkno
<
nblocks
;
blkno
++
)
{
{
...
@@ -282,8 +287,14 @@ lazy_scan_heap(Relation onerel, LVRelStats *vacrelstats,
...
@@ -282,8 +287,14 @@ lazy_scan_heap(Relation onerel, LVRelStats *vacrelstats,
buf
=
ReadBuffer
(
onerel
,
blkno
);
buf
=
ReadBuffer
(
onerel
,
blkno
);
/* In this phase we only need shared access to the buffer */
/* In this phase we only need shared access to the buffer unless we're
LockBuffer
(
buf
,
BUFFER_LOCK_SHARE
);
* going to do the vacuuming now which we do if there are no indexes
*/
if
(
nindexes
)
LockBuffer
(
buf
,
BUFFER_LOCK_SHARE
);
else
LockBufferForCleanup
(
buf
);
page
=
BufferGetPage
(
buf
);
page
=
BufferGetPage
(
buf
);
...
@@ -450,6 +461,12 @@ lazy_scan_heap(Relation onerel, LVRelStats *vacrelstats,
...
@@ -450,6 +461,12 @@ lazy_scan_heap(Relation onerel, LVRelStats *vacrelstats,
{
{
lazy_record_free_space
(
vacrelstats
,
blkno
,
lazy_record_free_space
(
vacrelstats
,
blkno
,
PageGetFreeSpace
(
page
));
PageGetFreeSpace
(
page
));
}
else
if
(
!
nindexes
)
{
/* If there are no indexes we can vacuum the page right now instead
* of doing a second scan */
lazy_vacuum_page
(
onerel
,
blkno
,
buf
,
0
,
vacrelstats
);
lazy_record_free_space
(
vacrelstats
,
blkno
,
PageGetFreeSpace
(
BufferGetPage
(
buf
)));
vacrelstats
->
num_dead_tuples
=
0
;
}
}
/* Remember the location of the last page with nonremovable tuples */
/* Remember the location of the last page with nonremovable tuples */
...
@@ -891,16 +908,20 @@ count_nondeletable_pages(Relation onerel, LVRelStats *vacrelstats,
...
@@ -891,16 +908,20 @@ count_nondeletable_pages(Relation onerel, LVRelStats *vacrelstats,
* See the comments at the head of this file for rationale.
* See the comments at the head of this file for rationale.
*/
*/
static
void
static
void
lazy_space_alloc
(
LVRelStats
*
vacrelstats
,
BlockNumber
relblocks
)
lazy_space_alloc
(
LVRelStats
*
vacrelstats
,
BlockNumber
relblocks
,
unsigned
nindexes
)
{
{
long
maxtuples
;
long
maxtuples
;
int
maxpages
;
int
maxpages
;
maxtuples
=
(
maintenance_work_mem
*
1024L
)
/
sizeof
(
ItemPointerData
);
if
(
nindexes
)
{
maxtuples
=
Min
(
maxtuples
,
INT_MAX
);
maxtuples
=
(
maintenance_work_mem
*
1024L
)
/
sizeof
(
ItemPointerData
);
maxtuples
=
Min
(
maxtuples
,
MaxAllocSize
/
sizeof
(
ItemPointerData
));
maxtuples
=
Min
(
maxtuples
,
INT_MAX
);
/* stay sane if small maintenance_work_mem */
maxtuples
=
Min
(
maxtuples
,
MaxAllocSize
/
sizeof
(
ItemPointerData
));
maxtuples
=
Max
(
maxtuples
,
MaxHeapTuplesPerPage
);
/* stay sane if small maintenance_work_mem */
maxtuples
=
Max
(
maxtuples
,
MaxHeapTuplesPerPage
);
}
else
{
maxtuples
=
MaxHeapTuplesPerPage
;
}
vacrelstats
->
num_dead_tuples
=
0
;
vacrelstats
->
num_dead_tuples
=
0
;
vacrelstats
->
max_dead_tuples
=
(
int
)
maxtuples
;
vacrelstats
->
max_dead_tuples
=
(
int
)
maxtuples
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录