In Oracle, a binary tree index on a NOT NULL column can be used to answer a COUNT(*). It will be faster in most cases than a FULL TABLE SCAN because indexes are usually smaller than their base table.
However, a regular binary tree index will still be huge with 157 Mrows. If your table is not updated concurrently (ie. only batch load process), then you might want to use a bitmap index instead.
The smallest bitmap index would be something like this:
CREATE BITMAP INDEX ix ON your_table(NULL);
Null entries are taken into account by a bitmap index. The resulting index will be tiny (20-30 8k blocks per million row) compared to either a regular binary tree index or the base table.
The resulting plan should show the following operations:
----------------------------------------------
| Id | Operation | Name |
----------------------------------------------
| 0 | SELECT STATEMENT | |
| 1 | SORT AGGREGATE | |
| 2 | BITMAP CONVERSION COUNT | |
| 3 | BITMAP INDEX FAST FULL SCAN| IX |
----------------------------------------------
If your table is updated concurrently, a bitmap index with a unique value will be a point of contention and shouldn't be used.
COUNT(*)so it can be helpful to have a narrow non-clustered index. Scanning the clustered index is usually the least efficient method since it is so wide (all columns included in it). – Paul White Oct 22 '12 at 22:36