xyjincan

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

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

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

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

    旧缓存数据定期删除。

    4 replies    2023-01-13 02:09:41 +08:00
    N46LzUbYtD2y37RN
        1
    N46LzUbYtD2y37RN  
       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   ·   3172 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 55ms · UTC 00:29 · PVG 08:29 · LAX 17:29 · JFK 20:29
    ♥ Do have faith in what you're doing.