首页 > 其他 > 详细

vacuum使用

时间:2021-09-03 22:59:08      阅读:28      评论:0      收藏:0      [点我收藏+]

https://blog.csdn.net/cuichao1900/article/details/100394801

ExecVacuum->vacuum->vacuum_rel->heap_vacuum_rel->lazy_scan_heap->lazy_vacuum_index函数的实现逻辑,该函数清理index relation

【测试流程】

postgres=# create table t2(id int,c1  varchar(40));
postgres=# insert into t2(id, c1) values(1,‘a‘);
INSERT 0 1
postgres=# select * from heap_page_items(get_raw_page(‘t2‘,0)) limit 10;
 lp | lp_off | lp_flags | lp_len | t_xmin | t_xmax | t_field3 | t_ctid | t_infomask2 | t_infomask | t_hoff | t_bits | t_oid |     t_data     
----+--------+----------+--------+--------+--------+----------+--------+-------------+------------+--------+--------+-------+----------------
  1 |   8160 |        1 |     30 |    579 |      0 |        0 | (0,1)  |           2 |       2050 |     24 |        |       | \x010000000561
(1 row)

postgres=# update t2 set c1=‘b‘ where id=1;
UPDATE 1
postgres=# select * from heap_page_items(get_raw_page(‘t2‘,0)) limit 10;
 lp | lp_off | lp_flags | lp_len | t_xmin | t_xmax | t_field3 | t_ctid | t_infomask2 | t_infomask | t_hoff | t_bits | t_oid |     t_data     
----+--------+----------+--------+--------+--------+----------+--------+-------------+------------+--------+--------+-------+----------------
  1 |   8160 |        1 |     30 |    579 |    580 |        0 | (0,2)  |       16386 |        258 |     24 |        |       | \x010000000561
  2 |   8128 |        1 |     30 |    580 |      0 |        0 | (0,2)  |       32770 |      10242 |     24 |        |       | \x010000000562
(2 rows)

postgres=# vacuum t2;
VACUUM
postgres=# select * from heap_page_items(get_raw_page(‘t2‘,0)) limit 10;
 lp | lp_off | lp_flags | lp_len | t_xmin | t_xmax | t_field3 | t_ctid | t_infomask2 | t_infomask | t_hoff | t_bits | t_oid |     t_data     
----+--------+----------+--------+--------+--------+----------+--------+-------------+------------+--------+--------+-------+----------------
  1 |      2 |        2 |      0 |        |        |          |        |             |            |        |        |       | 
  2 |   8160 |        1 |     30 |    580 |      0 |        0 | (0,2)  |       32770 |      10498 |     24 |        |       | \x010000000562

vacuum使用

原文:https://www.cnblogs.com/jiangshifu/p/15221418.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!