分析PostgreSQLDBA中新增的WAL选项
这篇文章主要讲解了“分析PostgreSQL DBA中新增的WAL选项”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“分析PostgreSQL DBA中新增的WAL选项”吧!
网站建设哪家好,找创新互联公司!专注于网页设计、网站建设、微信开发、小程序制作、集团企业网站建设等服务项目。为回馈新老客户创新互联还提供了珙县免费建站欢迎大家使用!
在PG 13中,explain命令增加了WAL选项,可查看命令执行过程中产生的WAL日志大小,对于写敏感的应用来说,可通过该命令观察WAL日志的统计信息.
新增的WAL选项
[local:/data/run/pg13]:5130 pg13@masterdb=# \help explain Command: EXPLAIN Description: show the execution plan of a statement Syntax: EXPLAIN [ ( option [, ...] ) ] statement EXPLAIN [ ANALYZE ] [ VERBOSE ] statement where option can be one of: ANALYZE [ boolean ] VERBOSE [ boolean ] COSTS [ boolean ] SETTINGS [ boolean ] BUFFERS [ boolean ] WAL [ boolean ] TIMING [ boolean ] SUMMARY [ boolean ] FORMAT { TEXT | XML | JSON | YAML } URL: https://www.postgresql.org/docs/devel/sql-explain.html [local:/data/run/pg13]:5130 pg13@masterdb=#
试用体验
执行checkpoint后运行SQL,WAL日志会写full page
[local:/data/run/pg13]:5130 pg13@masterdb=# checkpoint; CHECKPOINT [local:/data/run/pg13]:5130 pg13@masterdb=# explain (analyze,wal) update tmp set id = 1; QUERY PLAN ----------------------------------------------------------------------------------------------- ----------------------- Update on tmp (cost=0.00..23275.00 rows=1000000 width=10) (actual time=1636.839..1636.839 row s=0 loops=1) WAL: records=1999840 full page writes=8851 bytes=172345779 -> Seq Scan on tmp (cost=0.00..23275.00 rows=1000000 width=10) (actual time=4.686..100.211 rows=1000000 loops=1) Planning Time: 0.149 ms Execution Time: 1636.923 ms (5 rows)
再次执行SQL,没有写full page,日志大小相应的减少
[local:/data/run/pg13]:5130 pg13@masterdb=# explain (analyze,wal) update tmp set id = 1; QUERY PLAN ----------------------------------------------------------------------------------------------- ---------------------- Update on tmp (cost=0.00..23275.00 rows=1000000 width=10) (actual time=3661.261..3661.261 row s=0 loops=1) WAL: records=1999719 bytes=131982016 -> Seq Scan on tmp (cost=0.00..23275.00 rows=1000000 width=10) (actual time=3.920..98.921 rows=1000000 loops=1) Planning Time: 0.088 ms Execution Time: 3661.310 ms (5 rows)
节省23%的空间,38KB大小
[local:/data/run/pg13]:5130 pg13@masterdb=# select (172345779-131982016)/172345779::float; ?column? --------------------- 0.23420221391090756 (1 row) [local:/data/run/pg13]:5130 pg13@masterdb=# select (172345779-131982016)/1024/1024; ?column? ---------- 38 (1 row)
感谢各位的阅读,以上就是“分析PostgreSQL DBA中新增的WAL选项”的内容了,经过本文的学习后,相信大家对分析PostgreSQL DBA中新增的WAL选项这一问题有了更深刻的体会,具体使用情况还需要大家实践验证。这里是创新互联,小编将为大家推送更多相关知识点的文章,欢迎关注!
网站标题:分析PostgreSQLDBA中新增的WAL选项
网站URL:http://hbruida.cn/article/jdcgee.html