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

前端 未结 11 532
被撕碎了的回忆
被撕碎了的回忆 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:40

    You can have better performance by using the following method:

    SELECT COUNT(1) FROM (SELECT /*+FIRST_ROWS*/ column_name 
    FROM table_name 
    WHERE column_name = 'xxxxx' AND ROWNUM = 1);
    

提交回复
热议问题