Faster alternative in Oracle to SELECT COUNT(*) FROM sometable

前端 未结 11 525
被撕碎了的回忆
被撕碎了的回忆 2020-11-29 21:57

I\'ve notice that in Oracle, the query

SELECT COUNT(*) FROM sometable;

is very slow for large tables. It seems like the database it actual

11条回答
  •  野趣味
    野趣味 (楼主)
    2020-11-29 22:44

    This worked well for me

    select owner, table_name, nvl(num_rows,-1) 
    from all_tables 
    --where table_name in ('cats', 'dogs')
    order by nvl(num_rows,-1) desc
    

    from https://livesql.oracle.com/apex/livesql/file/content_EPJLBHYMPOPAGL9PQAV7XH14Q.html

提交回复
热议问题