Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Make SELECT COUNT(*) run faster

user13117585Mar 21 2014 — edited Mar 29 2014

Hello guys,

I'm back with a new question. I hope that you can help... I have a table with about 30 milion records. It has about 30 fields. Basically, it's not a huge table. I have tables with more records. But what I don't understand is why it takes so long to do a COUNT(*).

I have a UNIQUE index on the table which a compound index on 3 attributes. And when I check the plan, the index is correctly used to COUNT.

Plan hash value: 2669145199
---------------------------------------------------------------------------------------------
| Id  | Operation             | Name                        | Rows  | Cost (%CPU)| Time     |
---------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT      |                             |     1 | 16960   (7)| 00:02:24 |
|   1 |  SORT AGGREGATE       |                             |     1 |            |          |
|   2 |   INDEX FAST FULL SCAN| WORKFLOW_TASK_DOCUM_ID_IDX  |    29M| 16960   (7)| 00:02:24 |
---------------------------------------------------------------------------------------------

Don't trust that time. Because, it says 2minutes and 24 seconds. But in reality, it takes around 30 minutes. So I was wondering if any of you had an idea? Honestly, my query is just a SELECT COUNT(*) FROM MY_TABLE;

Thanks,

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 26 2014
Added on Mar 21 2014
24 comments
3,959 views