Skip to Main Content
  • Questions
  • Regarding high CPU usage for index query

Breadcrumb

Question and Answer

Chris Saxon

Thanks for the question, NarayanaSwamy.

Asked: November 08, 2016 - 9:00 am UTC

Last updated: November 08, 2016 - 9:38 am UTC

Version: Oracle

Viewed 1000+ times

You Asked

Hi
As part of a query execution we observed high CPU usage.

The query is using the indexed column in where condition.

Table :
Select * from mytable where mycol1 <= 200000 and xxxx

This table is having index on column mycol1.

This table will add and delete records very frequently(more than 1,00,000 add and delete per day) and the system is running for many days.

From the AWR I observed that the Segments by Logical Reads is high( 90%) for this table and for the index also the reads are high (8%)

One more thing is when I drop this column index and create another index(column not used in query) , this query is doing full table scan but CPU is much less when compared to the earlier case (with index)

Can you please help me to check why CPU is high when executing the query with index?

Thanks


and Chris said...

When your query uses the index it's almost certainly doing more work compared to the full table scan.

The way to check this is to capture the execution (repeat execution, NOT explain) plan for the query. Do this both for the indexed and full table scan versions.

The look at the total consistent (buffer) gets each does. You'll likely find the full table scan does far less. Less work = less CPU.

For details on how to get the execution plan read:

https://blogs.oracle.com/sql/entry/how_to_create_an_execution

If you want further help once you've done this, please post both execution plans here.

Is this answer out of date? If it is, please let us know via a Comment

More to Explore

Performance

Get all the information about database performance in the Database Performance guide.