暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

openGauss每日一练第19天 | 学习openGauss收集统计信息、打印执行计划、垃圾收集和checkpoint

原创 luooofan 2021-12-24
345
-- 1. create table test (id int) partition by range(id) ( partition test_p0 values less than(50), partition test_p1 values less than(100) ); insert into test values(generate_series(1, 99)); -- 包括了 99 -- 2. -- 默认是没有统计信息的 页数和元组数都是0 select relname, relpages, reltuples from pg_class where relname = 'test'; -- 更新统计信息 analyze VERBOSE test; -- 再次查询 有两页99个元组 select relname, relpages, reltuples from pg_class where relname = 'test'; -- ctid select ctid, * from test; -- 3. set explain_perf_mode=normal; explain select * from test; -- 迭代分区 迭代次数2 -- 分区内对表 test 的顺序扫描 create index test_idx on test(id); explain select * from test where id<10; -- 建了索引之后 select * 的执行计划并未变化,可能是由于该表只有一列的原因 -- 4. update test set id=id-1; select ctid, * from test; vacuum (verbose, analyze) test; select ctid, * from test; -- 5. drop table test;
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

文章被以下合辑收录

评论