最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

postgresql 如何查看pg_wal目錄下xlog文件總大小

 更新時(shí)間:2021年01月12日 14:50:59   作者:怠惰的小小白  
這篇文章主要介紹了postgresql 如何查看pg_wal目錄下xlog文件總大小的操作,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧

當(dāng)然如果你登錄服務(wù)器所在主機(jī),直接在$PGDAT/pg_wal下執(zhí)行:

du -h --max-depth=1 ./ 

可以得到。

#du -h --max-depth=1 ./
4.0K  ./archive_status
193M  ./

如果通過客戶端怎么做呢?

答案:pg_ls_waldir()函數(shù)。pg_ls_waldir()是pg 10.0引入的函數(shù),可以輸出數(shù)據(jù)庫WAL目錄的所有文件。

postgres=# select sum(size) from pg_ls_waldir();   
  sum  
-----------
 201326592
(1 row)

單位是byte,所以當(dāng)前pg_wal的xlog日志總大小為201326592/1024/1024=192M。

也可以使用:

postgres=# select count(*) from pg_ls_waldir();
 count 
-------
  12
(1 row)

12表示wal日志文件個(gè)數(shù),總大小12*16=192M。

16表示單個(gè)wal日志文件大小,單位MB,WAL 日志文件大小默認(rèn)為16MB。

bonus:

1、怎么調(diào)整單個(gè)wal日志文件大???

答:使用 initdb 調(diào)整WAL文件大小。

2、pg_ls_logdir() 也是pg10.0版本引入的函數(shù),輸出數(shù)據(jù)庫日志目錄的所有文件。

postgres=# select * from pg_ls_logdir();
        name        | size  |   modification   
----------------------------------+---------+------------------------
 postgresql-2020-04-28_092020.log | 2277343 | 2020-04-29 11:34:56+08
 postgresql-2020-04-28_092020.csv | 140050 | 2020-04-29 11:34:56+08

3、如何列出/data文件夾中的文件?

答:pg_ls_dir

postgres=# select pg_ls_dir('/data');
   pg_ls_dir    
----------------------

補(bǔ)充:postgresql 查看wal生成頻率和大小

–wal 文件生成數(shù)量

–linux ls --full-time stat filename

–pg_stat_file返回一個(gè)記錄,其中包含

– 1 size 文件尺寸

– 2 access 最后訪問時(shí)間戳(linux:最近訪問) 、

– 3 modification 最后修改時(shí)間戳(linux:最近更改–) 、

– 4 change 最后文件狀態(tài)改變時(shí)間戳(只支持 Unix 平臺)(linux:最近改動(dòng)) 、

– 5 creation 文件創(chuàng)建時(shí)間戳(只支持 Windows)

– 6 isdir 一個(gè)boolean指示它是否為目錄 isdir

– select * from pg_stat_file('/var/lib/postgresql/9.1/main/pg_xlog/0000000200000BBB000000A9');
– /var/lib/postgresql/9.1/main/pg_xlog
– /var/log/postgresql
– /mnt/nas_dbbackup/archivelog
with tmp_file as (
  select t1.file,
      t1.file_ls,
      (pg_stat_file(t1.file)).size as size,
      (pg_stat_file(t1.file)).access as access,
      (pg_stat_file(t1.file)).modification as last_update_time,
      (pg_stat_file(t1.file)).change as change,
      (pg_stat_file(t1.file)).creation as creation,
      (pg_stat_file(t1.file)).isdir as isdir
   from (select dir||'/'||pg_ls_dir(t0.dir) as file,
          pg_ls_dir(t0.dir) as file_ls
       from ( select '/var/lib/postgresql/9.1/main/pg_xlog'::text as dir
           --需要修改這個(gè)物理路徑
           --select '/mnt/nas_dbbackup/archivelog'::text as dir
           --select setting as dir from pg_settings where name='log_directory'
          ) t0
      ) t1 
   where 1=1
   order by (pg_stat_file(file)).modification desc
) 
select to_char(date_trunc('day',tf0.last_update_time),'yyyymmdd') as day_id,
    sum(case when date_part('hour',tf0.last_update_time) >=0 and date_part('hour',tf0.last_update_time) <24 then 1 else 0 end) as wal_num_all,
    sum(case when date_part('hour',tf0.last_update_time) >=0 and date_part('hour',tf0.last_update_time) <1 then 1 else 0 end) as wal_num_00_01,
    sum(case when date_part('hour',tf0.last_update_time) >=1 and date_part('hour',tf0.last_update_time) <2 then 1 else 0 end) as wal_num_01_02,
    sum(case when date_part('hour',tf0.last_update_time) >=2 and date_part('hour',tf0.last_update_time) <3 then 1 else 0 end) as wal_num_02_03,
    sum(case when date_part('hour',tf0.last_update_time) >=3 and date_part('hour',tf0.last_update_time) <4 then 1 else 0 end) as wal_num_03_04,
    sum(case when date_part('hour',tf0.last_update_time) >=4 and date_part('hour',tf0.last_update_time) <5 then 1 else 0 end) as wal_num_04_05,
    sum(case when date_part('hour',tf0.last_update_time) >=5 and date_part('hour',tf0.last_update_time) <6 then 1 else 0 end) as wal_num_05_06,
    sum(case when date_part('hour',tf0.last_update_time) >=6 and date_part('hour',tf0.last_update_time) <7 then 1 else 0 end) as wal_num_06_07,
    sum(case when date_part('hour',tf0.last_update_time) >=7 and date_part('hour',tf0.last_update_time) <8 then 1 else 0 end) as wal_num_07_08,
    sum(case when date_part('hour',tf0.last_update_time) >=8 and date_part('hour',tf0.last_update_time) <9 then 1 else 0 end) as wal_num_08_09,
    sum(case when date_part('hour',tf0.last_update_time) >=9 and date_part('hour',tf0.last_update_time) <10 then 1 else 0 end) as wal_num_09_10,
    sum(case when date_part('hour',tf0.last_update_time) >=10 and date_part('hour',tf0.last_update_time) <11 then 1 else 0 end) as wal_num_10_11,
    sum(case when date_part('hour',tf0.last_update_time) >=11 and date_part('hour',tf0.last_update_time) <12 then 1 else 0 end) as wal_num_11_12,
    sum(case when date_part('hour',tf0.last_update_time) >=12 and date_part('hour',tf0.last_update_time) <13 then 1 else 0 end) as wal_num_12_13,
    sum(case when date_part('hour',tf0.last_update_time) >=13 and date_part('hour',tf0.last_update_time) <14 then 1 else 0 end) as wal_num_13_14,
    sum(case when date_part('hour',tf0.last_update_time) >=14 and date_part('hour',tf0.last_update_time) <15 then 1 else 0 end) as wal_num_14_15,
    sum(case when date_part('hour',tf0.last_update_time) >=15 and date_part('hour',tf0.last_update_time) <16 then 1 else 0 end) as wal_num_15_16,
    sum(case when date_part('hour',tf0.last_update_time) >=16 and date_part('hour',tf0.last_update_time) <17 then 1 else 0 end) as wal_num_16_17,
    sum(case when date_part('hour',tf0.last_update_time) >=17 and date_part('hour',tf0.last_update_time) <18 then 1 else 0 end) as wal_num_17_18,
    sum(case when date_part('hour',tf0.last_update_time) >=18 and date_part('hour',tf0.last_update_time) <19 then 1 else 0 end) as wal_num_18_19,
    sum(case when date_part('hour',tf0.last_update_time) >=19 and date_part('hour',tf0.last_update_time) <20 then 1 else 0 end) as wal_num_19_20,
    sum(case when date_part('hour',tf0.last_update_time) >=20 and date_part('hour',tf0.last_update_time) <21 then 1 else 0 end) as wal_num_20_21,
    sum(case when date_part('hour',tf0.last_update_time) >=21 and date_part('hour',tf0.last_update_time) <22 then 1 else 0 end) as wal_num_21_22,
    sum(case when date_part('hour',tf0.last_update_time) >=22 and date_part('hour',tf0.last_update_time) <23 then 1 else 0 end) as wal_num_22_23, 
    sum(case when date_part('hour',tf0.last_update_time) >=23 and date_part('hour',tf0.last_update_time) <24 then 1 else 0 end) as wal_num_23_24
from tmp_file tf0
where 1=1
 and tf0.file_ls not in ('archive_status')
group by to_char(date_trunc('day',tf0.last_update_time),'yyyymmdd')
order by to_char(date_trunc('day',tf0.last_update_time),'yyyymmdd') desc
; 

以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教。

相關(guān)文章

  • PostgreSQL的外部數(shù)據(jù)封裝器fdw用法

    PostgreSQL的外部數(shù)據(jù)封裝器fdw用法

    這篇文章主要介紹了PostgreSQL的外部數(shù)據(jù)封裝器fdw用法,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2021-01-01
  • Postgresql備份和增量恢復(fù)方案

    Postgresql備份和增量恢復(fù)方案

    這篇文章主要給大家介紹了關(guān)于Postgresql備份和增量恢復(fù)的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對大家學(xué)習(xí)或者使用Postgresql具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2018-10-10
  • PostgreSQL設(shè)置時(shí)區(qū)、時(shí)間/日期函數(shù)匯總大全

    PostgreSQL設(shè)置時(shí)區(qū)、時(shí)間/日期函數(shù)匯總大全

    PostgreSQL是一款簡介而又性能強(qiáng)大的數(shù)據(jù)庫應(yīng)用程序,其在日期時(shí)間數(shù)據(jù)方面所支持的功能也都非常給力,這篇文章主要給大家介紹了關(guān)于PostgreSQL設(shè)置時(shí)區(qū)、時(shí)間/日期函數(shù)的相關(guān)資料,需要的朋友可以參考下
    2023-09-09
  • 查看PostgreSQL數(shù)據(jù)庫版本的方法小結(jié)

    查看PostgreSQL數(shù)據(jù)庫版本的方法小結(jié)

    這篇文章主要給大家介紹了關(guān)于如何查看PostgreSQL數(shù)據(jù)庫的版本,查看PostgreSQL?數(shù)據(jù)庫的版本號,可用方法很多,文中介紹了三種方法,對大家的學(xué)習(xí)或者工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2024-12-12
  • PostgreSQL圖(graph)的遞歸查詢實(shí)例

    PostgreSQL圖(graph)的遞歸查詢實(shí)例

    這篇文章主要給大家介紹了關(guān)于PostgreSQL圖(graph)的遞歸查詢的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對大家學(xué)習(xí)或者使用PostgreSQL具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-12-12
  • PostgreSQL數(shù)據(jù)庫遷移部署實(shí)戰(zhàn)教程

    PostgreSQL數(shù)據(jù)庫遷移部署實(shí)戰(zhàn)教程

    這篇文章主要介紹了PostgreSQL數(shù)據(jù)庫遷移部署實(shí)戰(zhàn)教程,由于項(xiàng)目本身就是基于PostgreSQL數(shù)據(jù)庫構(gòu)建的,因此數(shù)據(jù)庫遷移將變得十分便捷,接下來,我將簡要介紹我們的遷移步驟,需要的朋友可以參考下
    2023-07-07
  • 在windows下手動(dòng)初始化PostgreSQL數(shù)據(jù)庫教程

    在windows下手動(dòng)初始化PostgreSQL數(shù)據(jù)庫教程

    在windows下手動(dòng)初始化PG,是一件比較麻煩的事,下面我具體寫一下過程,大家做一下參考。
    2014-09-09
  • PostgreSQL對數(shù)組元素聚合基本方法示例

    PostgreSQL對數(shù)組元素聚合基本方法示例

    這篇文章主要為大家介紹了PostgreSQL對數(shù)組元素聚合基本方法示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2023-08-08
  • 使用psql操作PostgreSQL數(shù)據(jù)庫命令詳解

    使用psql操作PostgreSQL數(shù)據(jù)庫命令詳解

    這篇文章主要為大家介紹了使用psql操作PostgreSQL數(shù)據(jù)庫命令詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2023-08-08
  • PostgreSQL生成列實(shí)現(xiàn)過程介紹

    PostgreSQL生成列實(shí)現(xiàn)過程介紹

    PostgreSQL 12 增加新的特性——生成列(Generated Columns),也就是計(jì)算列。在之前版本也可以實(shí)現(xiàn),但需要定義函數(shù)和觸發(fā)器,利用該功能可以更容易使用并可以提升性能。生成列是給表指定計(jì)算列,其數(shù)據(jù)可以根據(jù)其他列數(shù)據(jù)自動(dòng)生成,當(dāng)原數(shù)據(jù)更新時(shí)其自動(dòng)更新
    2023-01-01

最新評論

溧水县| 巴楚县| 公安县| 前郭尔| 梅河口市| 米林县| 长沙市| 滨海县| 临邑县| 大余县| 辰溪县| 汪清县| 海林市| 勃利县| 奈曼旗| 通辽市| 曲周县| 阿合奇县| 崇义县| 济宁市| 富民县| 新沂市| 交城县| 灌云县| 顺义区| 辽阳市| 东丽区| 闸北区| 静宁县| 保定市| 安西县| 石首市| 阜南县| 临西县| 井研县| 汶上县| 莱阳市| 台东县| 明星| 康保县| 长葛市|