一个多星期前,我删除了 postgresql 表中的所有行(不是 via truncate
,而是 with delete from ...
)。Select count (*)
显示表行现在为 0。
当我现在运行查询以查询磁盘空间时,我仍然看到该表占用了空间。具体来说,所有索引仍然存在并且正在占用空间。如何摆脱它们并释放磁盘空间?其次,当我摆脱了所有行时,为什么它们仍然保留在首位?
以下是表格的详细说明,以防万一:
Table "public.links_photoobjectsubscription"
Column | Type | Modifiers
----------------+--------------------------+----------------------------------------------------------------------------
id | integer | not null default nextval('links_photoobjectsubscription_id_seq'::regclass)
viewer_id | integer | not null
updated_at | timestamp with time zone | not null
seen | boolean | not null
type_of_object | character varying(15) | not null
which_photo_id | integer |
which_link_id | integer |
which_group_id | integer |
which_salat_id | integer |
Indexes:
"links_photoobjectsubscription_pkey" PRIMARY KEY, btree (id)
"links_photoobjectsubscription_seen" btree (seen)
"links_photoobjectsubscription_updated_at" btree (updated_at)
"links_photoobjectsubscription_viewer_id" btree (viewer_id)
"links_photoobjectsubscription_which_photo_id" btree (which_photo_id)
Foreign-key constraints:
"links_photoobjectsubscription_viewer_id_fkey" FOREIGN KEY (viewer_id) REFERENCES auth_user(id) DEFERRABLE INITIALLY DEFERRED
"links_photoobjectsubscription_which_photo_id_fkey" FOREIGN KEY (which_photo_id) REFERENCES links_photo(id) DEFERRABLE INITIALLY DEFERRED
"which_group_id_photoobjectsubscription" FOREIGN KEY (which_group_id) REFERENCES links_group(id) ON DELETE CASCADE
"which_link_id_photoobjectsubscription" FOREIGN KEY (which_link_id) REFERENCES links_link(id) ON DELETE CASCADE
"which_salat_id_photoobjectsubscription" FOREIGN KEY (which_salat_id) REFERENCES links_salatinvite(id) ON DELETE CASCADE
从文档开始
VACUUM
您基本上需要发出一个命令来重写整个表(来自同一个文档),
在同一份文件中,
而且,从文档开始
TRUNCATE