Oracle的行计数表(按计数(*))与来自DBA_TABLES的NUM_ROWS个 [英] Oracle row count of table by count(*) vs NUM_ROWS from DBA_TABLES

查看:887
本文介绍了Oracle的行计数表(按计数(*))与来自DBA_TABLES的NUM_ROWS个的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

看起来count(*)比NUM_ROWS慢。

Looks like count(*) is slower than NUM_ROWS. Can experts in this area throw some light on this.

推荐答案

1)从下面的查询中获取NUM_ROWS意味着no.of rows值由 DBMS_STATS 更新。因此,它不包含表中的当前行数,而是在上次运行DBMS_STATS时计算的近似值。

1) Getting NUM_ROWS from the below query means that no.of rows value is updated by DBMS_STATS. So it does not contain the current number of rows in the table but an approximation calculated the last time DBMS_STATS was run.

SELECT table_name, 
       num_rows 
  FROM dba_tables 
 WHERE TABLE_NAME='NAME' 

要更新 DBA_TABLES 视图中的最新行计数值执行

To update the latest row count value in the DBA_TABLES view execute

exec dbms_stats.gather_schema_stats(ownname => 'NAME');

2)count(*)调用no的计算。从表中的行。

2) count(*) invokes a calculation of no. of rows from table.

这篇关于Oracle的行计数表(按计数(*))与来自DBA_TABLES的NUM_ROWS个的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆