Link to home
Start Free TrialLog in
Avatar of dba_damion
dba_damionFlag for Afghanistan

asked on

oracle Select count(*)

Select count(*) is taking some time in oracle to run. This could is in a vendor enterprise system and they can not change the code to select count(row_id) with out sending us a new update. Is there a way to trick the database to intreprite select count(*) from mytable to select count(row_id) from mytable. This table has long datatype. I tried to do a shrink in the test database  but it will not let you  
Avatar of msd1305
msd1305
Flag of United Arab Emirates image

No. unfortunately this is not possible. You have to change the code to either count(1) or count(row_id).

count(*) will definitely take lot more time if you have a long field in the table.
ASKER CERTIFIED SOLUTION
Avatar of Devinder Singh Virdi
Devinder Singh Virdi
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You can also think of increasing PARALLEL_EXECUTION_MESSAGE_SIZE or DB_FILE_MULTIBLOCK_READ_COUNT=0, therefore while doing Parallelism or fulltable scan oracle will read more resp.
Can you do explain plan on that particular SQL (select count(*))? I'd expect to see Index FFS if you've an index on any of those fields. Like the above post it should read the INDEX to get the count and that should be fast. Did you check you stat? Is it up to date?
Avatar of dba_damion

ASKER

virdi_ds
Adding primary key did it thank you
Great