I update statistics after imp.
If i execute select * from s where t=999, my index works.
if i execute select * from p, s where p.sysid=s.thing and.... it doesn't work, on prod. env. it does.
Main Topics
Browse All TopicsI imported a db from production environment to my test env.
In my test db every query i execute doesn't use any index (from Toad's Explain Plan).
Why? What have i to do di "rebuild" indexes?
I tryed to delete and rebuild indexes, update statistics but it doesn't work.
Thanks
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
>> The only way that seems to work it's to drop and re-create index
The only way what seems to work?
>> i don't know when statistics last updated
look at the LAST_ANALYZED and NUM_ROWS columns in user_tables. NUM_ROWS is the number of rows in the table at the time of the last analysis. This may be way off from the amount of data currently in the table.
>>Do you suggest to set statistics auto update?
updating statistics should only be done after large amounts of DML that may change the execution plans. There is no 1 silver bullet for all DBs.
Overall, Just because 1 system uses an index and another does not is not a bad thing. It's all based on the Cost Based Optimizer and the available statistics.
>>The only way what seems to work?
If i drop and create then index, my query uses this index.
>>look at the LAST_ANALYZED and NUM_ROWS columns in user_tables. NUM_ROWS is the number of rows in the table at the time of the last analysis. This may be way off from the amount of data currently in the table.
The only tables analized are PROFILE and SECURITY today.
Indexes have been analyed today.
I'm going to analyze all tables... is there a command to do this on all tables?
Again, Just because one explain plan uses indexes and another one doesn't does not imply there is a problem. There can be many factors for this. For example, is the test DB an EXACT copy of the production DB?
What are the results of your test query in production vs. test?
Does it return the exact same results from the same number of rows between the 2 systems?
What is the execution time difference between the 2 systems for this query?
Starting in 9i (I think) you can transfer just the statistics from one DB to another. This should cause the exact same execution plans.
Check out:
http://www.oracle-base.com
Did you maybe use the following options during the import :
INDEXES=N or CONSTRAINTS=N
It's that's the case then you don't have either the indexes or constraints in the TEST environment.
To validate this, do :
select count(1) from dba_indexes where owner = 'owner_here';
and
select count(1) from dba_constraints where owner = 'owner_here';
Example with owner = SYSTEM
select count(1) from dba_constraints where owner = 'SYSTEM';
if you don't have permission to use dba_ tables, then use user_indexes and user_constraints instead, without the where
in this case.
select count(1) from user_constraints;
Compare and see if all indexes and constraints were imported.
If every thing is there, check the status of the indexes
select object_name,status from dba_objects where owner = 'owner_here' and status != 'VALID' and object_type in
('INDEX','CONSTRAINT');
Business Accounts
Answer for Membership
by: slightwvPosted on 2005-02-01 at 09:01:58ID: 13194588
How long ago were the production statistics updated?
At most, just updating statistics should have been enough.