I need to drop a table but I want to be 100% sure the table is unused first. How can I do so with complete certainty?
I've already:
I suppose I can revoke permissions to the table from the application database user as a next step. What I would love is to be able to record table access to know for sure that table is not being referenced, but I wasn't able to find a way to do that over a specific timeframe.
And yes, I'm realize I'm being a bit paranoid (I could always restore the table from backup if it turns out it's needed) but I'm not a DBA so I'd prefer to be extra cautious.
创建表的备份,然后删除表,如果应用程序中断,那么您始终可以选择使用备份表重新创建它。
Paranoia is a virtue for a database administrator.
Revoking permissions seems like a good way to proceed.
To check if the table is used, observe the seq_scan
and idx_scan
columns of the pg_stat_user_tables
entry for the table. If these values don't change, the table is not accessed. These values are not 100% accurate, since statistics are deliberately sent via a UDP socket, but if the numbers don't change at all, you can be pretty certain that the table is unused.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.