您好,登錄后才能下訂單哦!
這篇文章主要講解了“分析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選項這一問題有了更深刻的體會,具體使用情況還需要大家實踐驗證。這里是億速云,小編將為大家推送更多相關知識點的文章,歡迎關注!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。