Skip to Main Content
  • Questions
  • SQL to find indexed and unindexed queries

Breadcrumb

Question and Answer

Connor McDonald

Thanks for the question.

Asked: February 08, 2019 - 7:29 pm UTC

Last updated: February 11, 2019 - 7:09 am UTC

Version: 11.2.0.4

Viewed 1000+ times

You Asked

Hi Guys,

Is there a way to determine the indexed and unindexed queries running on the database?

Thanks.

and Connor said...

It's not *really* as simple as that. What about a join that uses an index for one table, and not for another? Anyway, a quick approximation would be:

select s.sql_id, s.sql_text
from v$sqlstats s,
( select distinct sql_id
  from v$sql_plan
  where options like '%FULL%'
) p
where p.sql_id = s.sql_id


but are you sure that is *goal* here. Who cares if they are indexed or unindexed ? I thought perhaps the thing of interest really is "what queries are slow?"

For that you can also use v$sqlstats, and look at high values for:

executions
buffer_gets
disk_reads
elapsed_time



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.