美文网首页
postgresql快速获取表内行数

postgresql快速获取表内行数

作者: 木木111314 | 来源:发表于2023-02-01 15:34 被阅读0次

获取表的行数(非精确,速度快)

select c.* , b.*   FROM pg_class as c, pg_namespace as b  
where  c.relnamespace=b.oid and b.nspname ='sde' and c.relname='a'
select c.reltuples   FROM pg_class as c, pg_namespace as b  
where  c.relnamespace=b.oid and b.nspname ='sde' and c.relname='a'

4.517069e+06

获取某个表的 tuples

SELECT pg_stat_get_live_tuples('public.TableName'::regclass::oid);

更新统计信息

VACUUM (ANALYZE ) TableName
VACUUM ANALYZE  TableName
VACUUM FREEZE public.TableName;

相关文章

网友评论

      本文标题:postgresql快速获取表内行数

      本文链接:https://www.haomeiwen.com/subject/vcpihdtx.html