我们数据库的PostgreSQL未使用表,查询问题?

我们数据库的PostgreSQL未使用表,查询问题?,postgresql,performance,Postgresql,Performance,有没有办法找出数据库中的旧表和未使用的表来删除它们? 我们正在使用PostgreSQL数据库 我假设“未使用的表”意味着它没有行 运行以下查询以列出行数为零的所有表: select table_name, pg_relation_size(quote_ident(table_name)) from information_schema.tables where table_schema = 'public' order by 2 如果您使用的是不同的架构,请替换public。如果架构不在您的

有没有办法找出数据库中的旧表和未使用的表来删除它们? 我们正在使用PostgreSQL数据库

我假设“未使用的表”意味着它没有行

运行以下查询以列出行数为零的所有表:

select table_name, pg_relation_size(quote_ident(table_name)) 
from information_schema.tables
where table_schema = 'public'
order by 2

如果您使用的是不同的架构,请替换
public

如果架构不在您的
search\u路径上,则必须修改查询。什么是“未使用”表?空表还是未查询表?