数据库数据目录下 base 文件夹有很多 1GB 大小文件,占用几百 G 空间 - V2EX
xyjincan

数据库数据目录下 base 文件夹有很多 1GB 大小文件,占用几百 G 空间

  •  
  •   xyjincan Jan 11, 2023 2206 views
    This topic created in 1228 days ago, the information mentioned may be changed or developed.

    怎么清零出空间呢,数据库表里面数据不多

    建立了额外的四个表空间独立存储每月新增数据。

    旧缓存数据定期删除。

    4 replies    2023-01-13 02:09:41 +08:00
    n0099
        1
    n0099  
       Jan 11, 2023   1
    > 1GB 大小文件

    这是 pgsql 的一个文件分片机制: https://www.postgresql.org/docs/current/storage-file-layout.html
    > When a table or index exceeds 1 GB, it is divided into gigabyte-sized segments. The first segment's file name is the same as the filenode; subsequent segments are named filenode.1, filenode.2, etc. This arrangement avoids problems on platforms that have file size limitations. (Actually, 1 GB is just the default segment size. The segment size can be adjusted using the configuration option --with-segsize when building PostgreSQL.) In principle, free space map and visibility map forks could require multiple segments as well, though this is unlikely to happen in practice.

    根据
    https://dba.stackexchange.com/questions/48273/whats-stored-in-data-dir-base-of-postgresql
    https://dba.stackexchange.com/questions/228114/why-is-my-postgres-base-directory-filling-up-rapidly
    您有执行过[VACUUM]( https://www.postgresql.org/docs/current/routine-vacuuming.html#VACUUM-FOR-SPACE-RECOVERY)吗
    xyjincan
        2
    xyjincan  
    OP
       Jan 11, 2023
    @h0099 第一次知道 PostgreSQL 的 VACUUM ,没有执行过。
    cstj0505
        3
    cstj0505  
       Jan 11, 2023
    vacuum full xx 表
    会锁表。
    ericFork
        4
    ericFork  
       Jan 13, 2023
    pg_repack 或者类似的工具了解一下
    About     Help     Advertise     Blog     API     FAQ     Solana     2968 Online   Highest 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 43ms UTC 03:43 PVG 11:43 LAX 20:43 JFK 23:43
    Do have faith in what you're doing.
    ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86