由于在postgres历史表里面存在了很多历史记录占满了硬盘空间,我用delete命令将此表清空,之后再用df -h命令查看,硬盘空间还是满的,没有减少,我是不是少执行了什么命令?请各位指点一下,谢谢.

解决方案 »

  1.   

    我用了VACUUM这条命令,这条命令主要是清理和分析postgres数据库,但执行完了再用 df -h 查看,还是一样。硬盘空间还是一样没有少,我删除了300多万条记录,不可能空间一点都没少。
      

  2.   

    PostgreSQL's VACUUM command has to run on a regular basis for several reasons: To recover or reuse disk space occupied by updated or deleted rows. 
    To update data statistics used by the PostgreSQL query planner. 
    To protect against loss of very old data due to transaction ID wraparound. 
    VACUUM FULL is recommended for cases where you know you have deleted the majority of rows in a table, so that the steady-state size of the table can be shrunk substantially with VACUUM FULL's more aggressive approach. Use plain VACUUM, not VACUUM FULL, for routine vacuuming for space recovery
    用了vacuum full没有
      

  3.   

    如果你的历史表可以清空的话,试试看TRUNCATE table