Search This Blog

Wednesday, December 7, 2011

Demantra performance issue

Issue: User is not able open worksheets
Solution: Rebuild the schema
Step 1) 
# ---------------------------------------------------------------------------
# Clean temp_tables and rebuild msdem schema
# ---------------------------------------------------------------------------
sqlplus /nolog << EOF
conn msdem/******
col PCT_CHAIN_CNT for  999.99
spool /tmp/${ORACLE_SID}_demantra_maintenance.log
select 'Start drop_temps at '|| to_char(sysdate,'YYYY-MON-DD HH24:MI:SS') from dual;
exec DROP_TEMPS(0);
select count(1) from audit_values;
select 'Start drop_temps at '|| to_char(sysdate,'YYYY-MON-DD HH24:MI:SS') from dual;
exec clean_log_tables();
select count(1) from audit_values;
select 'Start rebuild_schema at '|| to_char(sysdate,'YYYY-MON-DD HH24:MI:SS') from dual;
Select table_name,num_rows, chain_cnt,(chain_cnt/num_rows)*100 pct_chain_cnt
from user_tables where chain_cnt >  0 order by chain_cnt desc;
exec rebuild_schema('1');
Select table_name,num_rows, chain_cnt,(chain_cnt/num_rows)*100 pct_chain_cnt
from user_tables where chain_cnt >  0 order by chain_cnt desc;
select 'Start exception_checking at '|| to_char(sysdate,'YYYY-MON-DD HH24:MI:SS') from dual;
select  to_char(err_date,'YYYYY-MON-DD HH24:MI:SS')||'|'||
proc_name||'|'||err_msg  from db_exception_log where trunc(err_date)=trunc(sysdate);
spool off
@ /home/oracle/dba/gen_msdem_index_rebuild.sql
@ /home/oracle/dba/msdem_index_rebuild.sql
EOF


Step 2)
Rebuild table and index
alter table MDP_MATRIX move; -- connect to object owner and start
select 'alter index '||INDEX_NAME ||' rebuild online nologging parallel 8;' from user_indexes where
table_name='MDP_MATRIX' and status='UNUSABLE';
select INDEX_NAME,status from user_indexes where table_name='MDP_MATRIX' and
status='UNUSABLE';
alter index SALES_DATA_LUD_IDX rebuild online nologging parallel 8;
ANALYZE table MSDEM.MDP_MATRIX estimate statistics sample 10 percent;
Gather stats
exec DBMS_STATS.GATHER_TABLE_STATS('MSDEM','SALES_DATA',NULL,5,FALSE,'FOR ALL COLUMNS SIZE 1',5,'ALL',TRUE);
exec DBMS_STATS.GATHER_TABLE_STATS('MSDEM','MDP_MATRIX',NULL,5,FALSE,'FOR ALL COLUMNS SIZE 1',5,'ALL',TRUE);
execute dbms_stats.gather_schema_stats (ownname => 'MSDEM', estimate_percent => 50, degree => 5, cascade => true);
use below querry to compare the data after gather stats.
SQL> select count(*) from mdp_matrix
COUNT(*)
----------
222400
@@@@@@@@@chaning row information@@@@@@@
select table_name, chain_cnt, num_rows, (chain_cnt/num_rows)*100 percent
from user_tables where chain_cnt >0 and num_rows > 0 order by chain_cnt desc;
SELECT table_name, tablespace_name, chain_cnt, num_rows, (chain_cnt / num_rows) * 100 PERCENT, last_analyzed FROM user_tables
WHERE chain_cnt > 0 AND num_rows > 0;
SELECT TABLE_NAME, CHAIN_CNT, NUM_ROWS, (CHAIN_CNT/NUM_ROWS)*100 PERCENT FROM USER_TABLES where table_name='MDP_MATRIX';



No comments:

Post a Comment

Transportable tablespace refresh

  1.check tablespace for the user which need to refresh -------------------------------------------------------------------  SQL> select ...