count(1),count(*),count(rowid)
下面是三个语句的测试结果,测试表的数据为25341223行(千万级)
SQL> alter system flush shared_pool; System altered Executed in 0.047 seconds SQL> select count(1) from thqlog; COUNT(1) ---------- 25341223 Executed in 12.297 seconds SQL> alter system flush shared_pool; System altered Executed in 0.062 seconds SQL> select count(*) from thqlog 2 ; COUNT(*) ---------- 25341223 Executed in 12.563 seconds SQL> alter system flush shared_pool; System altered Executed in 0.047 seconds SQL> select count(rowid) from thqlog; COUNT(ROWID) ------------ 25341223 Executed in 12.172 seconds
从测试结果来看,count(rowid)> count(1) > count(*)
简单做人 从容做事 快乐生活