Oracle performance finetuning…Select count(*)

Many times we used this query to show total number of pages or some other purpose.

SELECT count(*) from TABLE_NAME
Pros – Provides exact number
Cons: Takes longer time, based on total number of records

SELECT table_name, num_rows FROM ALL_TABLES where table_name = ‘TABLE_NAME’
Cons: Not accurate (may be 1%) numbers in run time, but good enough for business purpose in many cases.
Pros: Pretty fast

SELECT table_name, num_rows FROM ALL_TABLES where OWNER=’asdf’ order by num_rows desc

-o-