Search code examples
oracle11gpaginationquery-optimization

SELECT COUNT() or SELECT * optimization


I'm using Oracle 11g as my Database.I'm trying to do pagination from database side.

I have to get record count on table. and there is a 100K recodes and it take around 2 mins.What I'm trying to do using pagination is, to get X number of records to show in the first page; then next page shows the next X number of records and so on.

Is it take the same amount of time to get the 'COUNT()' from a db table as it would take to fetch those rows with data?

Are there any methods or any logic to do this kind of task (EXCEPT INDEXING).

Thank you.


Solution

  • Both will take considerable amount of time since it has to read across the whole table. But Count(*) takes more time than SELECT *