I created Script that will rebuild indexes per schema. I wanted to post for others to enjoy.
BEGIN
FOR INDEx_RECORD IN (select 'SCHEMA_NAME.'||object_name as obj
from dba_objects
where object_type = 'INDEX' and
owner ='SCHEMA_NAME'
) LOOP
execute immediate 'ALTER INDEX '||INDEx_RECORD.obj||' REBUILD';
END LOOP; -- implicit CLOSE occurs
END;
Thank you very much, I'm sure somebody will really enjoy it.
so...
... why are you rebuilding all indexes on the schema? any special reason?
... since you are not doing rebuild online you are going to certainly affect business.
... how about partitioned indexes?
... how about statistics?
... have a couple more but I'll wait until you get these solved
Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.
I created Script that will rebuild indexes per schema. I wanted to post for others to enjoy.
BEGIN
FOR INDEx_RECORD IN (select 'SCHEMA_NAME.'||object_name as obj
from dba_objects
where object_type = 'INDEX' and
owner ='SCHEMA_NAME'
) LOOP
execute immediate 'ALTER INDEX '||INDEx_RECORD.obj||' REBUILD';
END LOOP; -- implicit CLOSE occurs
END;
what a dangerous script to post - i hope you feel ashamed
I have an application that likes to delete 36 million rows out of the database per week. It's not a well written app. I really did not want to resort to rebuilding indexes but i seem to have no choice. We are not up 24 x 7. This is done with no users on. So yes please be careful. If you have any better ideas I'm certainly open to hear them.
Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.
There are many queries that go from running in 15mins to 6 hours after about 10 days. The queries are all based on joining of many views. Each of those views many up of many extremely wide tables.
I took a close look at one particular query. First, I tried to make sure I had updated statistics. No affect. Next, I rebuilt the indexes for that query. It returned to a 15min query.
I rebuilt indexes once a week for 3 weeks. The query ran consistently in 15 min. Then I rebuilt indexes for the entire schema. All queries run consistently in 15min.
There is nothing I can do about the SQL. I've been told it cannot be changed.
Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.
Bookmarks