0

I am currently running into an issue with my Oracle instance. I have two simple select statements:

select * from dog_vets  

and

select * from dog_statuses

and the following fiddle

My explain plan on dog_vets is as follows:

 0 | Select Statement  
 1 | Table Access Full Scan dog_vets

my explain plan on dog_statuses is as follows:

ID|Operation | Name | Rows |Bytes | cost | time    
0 | Select Statement |  | 20G | 500M | 100000 | 999:99:17  
1 | View  | index%_join_001 | 20G | 500M | 100000 | 999:99:17  
2 | Hash Join  |  | | | |   
3 | Hash Join  |  | | | |   
4 | Index fast full scan dog_statuses_check_up  |  | 20G | 500M | 100000 | 32:15:00  
5 | Index fast full scan dog_statuses_sick|  | 20G | 500M | 100000 | 35:19:00  

To get this type of output execute the following statement:

explain plan for   
select * from dog_vets;

OR

 explain plan for   
    select * from dog_statuses;

and then

select * from table(dbms_xplan.display);

Now my question is, why do multiple indexes imply a view (materialized I assume) being created in my above statements and further what type of performance hit am I suffering on this type of query? As it stands now dog_vets has ~300 million records and dog_Statuses has about 500 million. I have yet to be able to get select * from dog_statuses to return in under 10 hours. This is primarily because the query dies before it completes.

DDL

In case sql fiddle dies:

create table dog_vets
(
     name varchar2(50),
     founded timestamp,
     staff_count number
  );

create table dog_statuses
(
      check_up timestamp,
      sick varchar2(1)
  );


create index dog_vet_name
on dog_vets(name);

create index dog_status_check_up
on dog_statuses(check_up);

create index dog_status_sick
on dog_statuses(sick);
16
  • Are you sure dog_statuses is a table? Maybe it is indeed a view. What does select object_type from all_objects where object_name = 'DOG_STATUSES'; return?
    – user330315
    Oct 19, 2012 at 11:52
  • It returns table on my database.
    – Woot4Moo
    Oct 19, 2012 at 11:54
  • 2
    Can you show the full execution plan? Btw: what do you plan to do with the 500 million rows that you retrieve? You can't possibly keep them in memory or display them to the user.
    – user330315
    Oct 19, 2012 at 12:07
  • 1
    I'm talking about the details for each step. If DOG_STATUSES is indeed a table, then there must be a reason for that, and that can only be seen with a detailed and complete execution plan.
    – user330315
    Oct 19, 2012 at 12:18
  • 1
    @Woot4Moo: I think what we want is more confidence that the code we look at is actually the code that's causing the problem. Personally, I'd like to see the SQL DDL for dog_vets and dog_statuses pasted from the production system. That word pasted is important. Also, tell us what version of Oracle is in use on the system that's causing the problem. Oct 19, 2012 at 18:41

1 Answer 1

0

You could try to tell the optimizer to forget about indexes

 SELECT /*+NO_INDEX(dog_statuses)*/ *
 FROM dog_statuses

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.