Search This Blog

Total Pageviews

Wednesday, 29 June 2011

Oracle 11g ADDM Report for Oracle RAC

ADDM Report
ADDM for RAC
DBMS_ADDM for RAC




SELECT MIN(snap_id), MAX(snap_id) FROM dba_hist_snapshot;





All instance in RAC ...
_________________________



VAR tname VARCHAR2(30);
VAR start_snap_id number;
VAR end_snap_id number;

BEGIN

:tname := 'DB_TEST_ANUJ';
:start_snap_id := 884 ;
:end_snap_id := 1052 ;
DBMS_ADDM.ANALYZE_DB(:tname, :start_snap_id, :end_snap_id);

END;



DBMS_ADDM for particulate Instance
_________________________________


VAR tname VARCHAR2(30);
VAR start_snap_id number;
VAR end_snap_id number;
VAR INST_NUM number;
BEGIN
:tname := 'INST_TEST_ANUJ';
:start_snap_id := 884 ;
:end_snap_id := 1052 ;
:INST_NUM := 1;
DBMS_ADDM.ANALYZE_INST(:tname,:start_snap_id,:end_snap_id, :INST_NUM );
END;
/





DBMS_ADDM for  partial mode
___________________________


DBMS_ADDM

analyze instance 1 and 3 out of four node RAC



VAR tname VARCHAR2(30);
VAR start_snap_id number;
VAR end_snap_id number;

BEGIN

:tname := 'PART_MODE_TEST_ANUJ';
:start_snap_id :=884;
:end_snap_id := 1052 ;
DBMS_ADDM.ANALYZE_PARTIAL(:tname,'1,3', :start_snap_id, :end_snap_id);

END;

/



ADDM report output 
__________________


SET LONG 500000 PAGESIZE 0;
SELECT DBMS_ADDM.GET_REPORT(:tname) FROM DUAL;

or

SELECT DBMS_ADDM.GET_REPORT('INST_TEST_ANUJ') FROM DUAL;

===========





 SELECT MIN(snap_id), MAX(snap_id) FROM dba_hist_snapshot;


BEGIN
-- 
DBMS_ADVISOR.create_task (advisor_name => 'ADDM',task_name => '33033_33035_AWR_SNAPSHOT',task_desc => 'Advisor for snapshots 33033 to 33035');
DBMS_ADVISOR.set_task_parameter (task_name => '33033_33035_AWR_SNAPSHOT',parameter => 'START_SNAPSHOT',value => 33033);
DBMS_ADVISOR.set_task_parameter ( task_name => '33033_33035_AWR_SNAPSHOT',parameter => 'END_SNAPSHOT',value => 33035);
DBMS_ADVISOR.execute_task(task_name => '33033_33035_AWR_SNAPSHOT');
END;
/


SET LONG 100000
SET PAGESIZE 50000
SELECT DBMS_ADVISOR.get_task_report('33033_33035_AWR_SNAPSHOT') AS report FROM dual; 



=============

some sql !!!



set linesize 500 pagesize 300
col ACTION_MESSAGE for a70 wrap 
col MESSAGE for a50 wrap
 Select a.execution_end, b.type, b.impact, d.rank, d.type,
'Message:'|| b.message MESSAGE,
'Command To correct:'||c.command COMMAND,
'Action Message:'|| c.message ACTION_MESSAGE
From dba_advisor_tasks a, dba_advisor_findings b,Dba_advisor_actions c, dba_advisor_recommendations d
Where a.owner=b.owner
and a.task_id=b.task_id
And b.task_id=d.task_id
and b.finding_id=d.finding_id
And a.task_id=c.task_id
and d.rec_id=c.rec_Id
And a.task_name like 'ADDM%'
and a.status='COMPLETED'
and to_char(execution_end,'dd/mm/yyyy')='06/05/2021'
Order by 3 desc;



set linesize 500 pagesize 300
col ACTION_MESSAGE for a70 wrap 
col MESSAGE for a50 wrap
 Select a.execution_end, b.type, b.impact, d.rank, d.type,
'Message:'|| b.message MESSAGE,
'Command To correct:'||c.command COMMAND,
'Action Message:'|| c.message ACTION_MESSAGE
From dba_advisor_tasks a, dba_advisor_findings b,Dba_advisor_actions c, dba_advisor_recommendations d
Where a.owner=b.owner
and a.task_id=b.task_id
And b.task_id=d.task_id
and b.finding_id=d.finding_id
And a.task_id=c.task_id
and d.rec_id=c.rec_Id
And a.task_name like 'ADDM%'
and a.status='COMPLETED'
and to_char(execution_end,'dd/mm/yyyy')='06/05/2021'
Order by 3 desc;

EXECUTION TYPE            IMPACT       RANK TYPE                           MESSAGE                                            COMMAND                                                                            ACTION_MESSAGE
--------- ----------- ---------- ---------- ------------------------------ -------------------------------------------------- ----------------------------------------------------------------------------------- ----------------------------------------------------------------------
06-MAY-21 PROBLEM      338002056          2 SQL Tuning                     Message:SQL statements consuming significant datab Command To correct:UNDEFINED                                                       Action Message:Investigate the PL/SQL statement with SQL_ID "b6usrg82h
                                                                           ase time were found. These statements offer a good                                                                                    wsa3" for possible performance improvements. You can supplement the in
                                                                            opportunity for performance improvement.                                                                                             formation given here with an ASH report for this SQL_ID.

06-MAY-21 PROBLEM      338002056          4 SQL Tuning                     Message:SQL statements consuming significant datab Command To correct:UNDEFINED                                                       Action


set linesize 300 pagesize 300
col ACTION_MESSAGE for a150 wrap
Select distinct c.message ACTION_MESSAGE
From dba_advisor_tasks a, dba_advisor_findings b,Dba_advisor_actions c,
dba_advisor_recommendations d
Where a.owner=b.owner and a.task_id=b.task_id
And b.task_id=d.task_id and b.finding_id=d.finding_id
And a.task_id=c.task_id and d.rec_id=c.rec_Id
And a.task_name like 'ADDM%' and a.status = 'COMPLETED'
-- And c.message like '%involving I/O on TABLE%'
--And c.message like 'Investigate application logic involving I/O on TABLE%'
Order by 1;

ACTION_MESSAGE
------------------------------------------------------------------------------------------------------------------------------------------------------
Consider not using the compression option for RMAN jobs. Alternatively, consider slowing down RMAN activity, or scheduling RMAN jobs when user activit
y is lower.

Increase the size of the SGA by setting the parameter "sga_target" to 4608 M.
Increase the size of the SGA by setting the parameter "sga_target" to 5120 M.
Increase the size of the SGA by setting the parameter "sga_target" to 5632 M.
Increase the size of the SGA by setting the parameter "sga_target" to 6144 M.
Increase the size of the SGA by setting the parameter "sga_target" to 6656 M.
Increase the size of the SGA by setting the parameter "sga_target" to 7168 M.
Increase the size of the SGA on affected instances. Check the ADDM analysis of affected instances for more details.
Increase throughput of the Global Cache Service (LMSn) processes. Increase the number of Global Cache Service processes by increasing the value of the
 parameter "gcs_server_processes". Alternatively, if the host is CPU bound consider increasing the OS priority of the Global Cache Service processes.

Investigate application logic involving I/O on database object with ID 82.
Investigate application logic to eliminate parse errors.
Investigate appropriateness of DDL operations.
Investigate the PL/SQL statement with SQL_ID "b6usrg82hwsa3" for possible performance improvements. You can supplement the information given here with
 an ASH report for this SQL_ID.



Set pages 1000 lines 300 
col ACTION_MESSAGE for a70
col MESSAGE for a20
col COMMAND for a15
Select a.execution_end, b.type, b.impact, d.rank, d.type,
'Message           : '||b.message MESSAGE,
'Command To correct: '||c.command COMMAND,
'Action Message    : '||c.message ACTION_MESSAGE
from dba_advisor_tasks a, dba_advisor_findings b,dba_advisor_actions c, dba_advisor_recommendations d
where a.owner=b.owner and a.task_id=b.task_id
and b.task_id=d.task_id and b.finding_id=d.finding_id
and a.task_id=c.task_id and d.rec_id=c.rec_Id
and a.task_name like 'ADDM%' 
and a.status='COMPLETED'
and a.description like '%53996%'  --- <<<< from above sql 
and d.type='SQL Tuning'
-- and b.owner not in ('SYS','SYSTEM')
-- and a.description like (select snap_id from (select snap_id  from dba_hist_snapshot order by begin_interval_time desc) where rownum < 3)
Order by b.impact, d.rank;



Set pages 1000 lines 300 
col ACTION_MESSAGE for a70
col MESSAGE for a20
col COMMAND for a15
Select a.execution_end, b.type, b.impact, d.rank, d.type,
'Message           : '||b.message MESSAGE,
'Command To correct: '||c.command COMMAND,
'Action Message    : '||c.message ACTION_MESSAGE
from dba_advisor_tasks a, dba_advisor_findings b,dba_advisor_actions c, dba_advisor_recommendations d
where a.owner=b.owner and a.task_id=b.task_id
and b.task_id=d.task_id and b.finding_id=d.finding_id
and a.task_id=c.task_id and d.rec_id=c.rec_Id
and a.task_name like 'ADDM%' 
and a.status='COMPLETED'
--and a.description like '%b742waswg25n7_tuning_task11%'  --- <<<< from above sql 
and d.type='SQL Tuning'
-- and b.owner not in ('SYS','SYSTEM')
-- and a.description like (select snap_id from (select snap_id  from dba_hist_snapshot order by begin_interval_time desc) where rownum < 3)
--and a.execution_end > sysdate -1
Order by b.impact, d.rank;
===


select round((ratio_to_report(max(Benefit)) over () *100)) as overall_benefit_pct
, type
, min(benefit) min_benefit
, max(Benefit) max_benefit
, count(*) cnt
from dba_Advisor_recommendations 
where type is not null 
group by type 
order by 1 desc 
;

col command for a15
col message for a100
select command, message , count(*)  from dba_advisor_Actions
group by command, message 
;




col TASK_NAME for a27
col description for a100
select task_name, description, created from dba_advisor_tasks
where advisor_name = 'ADDM'
and created > sysdate -7
order by created desc;

SELECT type, count(*) FROM dba_advisor_findings NATURAL JOIN dba_advisor_tasks WHERE created between sysdate -1 and sysdate GROUP BY type

SELECT distinct message FROM dba_advisor_recommendations JOIN dba_advisor_findings USING (finding_id, task_id) WHERE rank = 0;



SET LONG 500000 PAGESIZE 0
SELECT DBMS_ADDM.GET_REPORT('ADDM:1825264339_1_19982') FROM DUAL;




Monday, 27 June 2011

Oracle DBMS_ADVISOR.SQLACCESS_ADVISOR

Oracle QUICK_TUNE
Oracle quick tune
SQLACCESS_ADVISOR


SQL> connect scott/tiger
Connected.

SQL> select * from tab;

TNAME TABTYPE CLUSTERID
------------------------------ ------- ----------
BONUS TABLE
DEPT TABLE
EMP TABLE <<<<<<<<<<<<<<,---------------
SALGRADE TABLE
T TABLE



from sys



SQL> connect / as sysdba
Connected.
SQL>
SQL>
SQL>
SQL>
SQL> BEGIN
DBMS_ADVISOR.quick_tune(
advisor_name => DBMS_ADVISOR.SQLACCESS_ADVISOR,
task_name => 'emp_quick_tune',
attr1 => 'SELECT * FROM scott.emp WHERE EMPNO = 7788');
END;
/

PL/SQL procedure successfully completed.


SQL> SET LONG 100000
SET PAGESIZE 50000
SELECT DBMS_ADVISOR.get_task_script('emp_quick_tune') AS script
FROM dual;
SET PAGESIZE 24


SQL> SQL> 2
SCRIPT
--------------------------------------------------------------------------------
Rem SQL Access Advisor: Version 11.2.0.1.0 - Production
Rem
Rem Username: SYS
Rem Task: emp_quick_tune
Rem Execution date:
Rem

/* RETAIN INDEX "SCOTT"."PK_EMP" */



or



VARIABLE task_name VARCHAR2(255);
VARIABLE sql_stmt VARCHAR2(4000);
exec :sql_stmt := 'SELECT COUNT(*) FROM scott.emp WHERE empno = 999';
exec :task_name := 'ANUJ_QUICKTUNE_TASK';
exec DBMS_advisor.quick_tune (dbms_advisor.sqlaccess_advisor, :task_name, :sql_stmt);


SET LONG 100000
SET PAGESIZE 50000
SELECT DBMS_ADVISOR.get_task_script('ANUJ_QUICKTUNE_TASK') AS script FROM dual;
SET PAGESIZE 24



======================================




begin
-- a task and a workload will be created then the task will be executed
DBMS_ADVISOR.QUICK_TUNE(
ADVISOR_NAME => DBMS_ADVISOR.SQLACCESS_ADVISOR,
TASK_NAME => 'anuj_quick_tune',
ATTR1 => 'select * from scott.emp where EMPNO=123');

end;



SQL> begin
-- a task and a workload will be created then the task will be executed
DBMS_ADVISOR.QUICK_TUNE(
ADVISOR_NAME => DBMS_ADVISOR.SQLACCESS_ADVISOR,
TASK_NAME => 'anuj_quick_tune',
ATTR1 => 'select * from scott.emp where EMPNO=123');

end;
/

PL/SQL procedure successfully completed.



col ERROR_MESSAGE format a50
select TASK_NAME, STATUS, PCT_COMPLETION_TIME, ERROR_MESSAGE from DBA_ADVISOR_LOG where TASK_NAME ='anuj_quick_tune';

TASK_NAME STATUS PCT_COMPLETION_TIME ERROR_MESSAGE
------------------------------ ----------- ------------------- --------------------------------------------------
anuj_quick_tune COMPLETED 100

1 row selected.


SET LONG 100000
SET PAGESIZE 50000
SELECT DBMS_ADVISOR.GET_TASK_SCRIPT('anuj_quick_tune') AS script FROM dual;

SCRIPT
--------------------------------------------------------------------------------
Rem SQL Access Advisor: Version 11.2.0.1.0 - Production
Rem
Rem Username: SYS
Rem Task: anuj_quick_tune
Rem Execution date:
Rem

/* RETAIN INDEX "SCOTT"."SYS_C0022543" */



1 row selected.



-- if you need to terminate the executing task (may be time consuming)

exec DBMS_ADVISOR.CANCEL_TASK(TASK_NAME =>'anuj_quick_tune');



select REC_ID, RANK, BENEFIT, TYPE "Recommendation Type"
from DBA_ADVISOR_RECOMMENDATIONS
where TASK_NAME = 'anuj_quick_tune'
order by RANK;


REC_ID RANK BENEFIT Recommendation Type
---------- ---------- ---------- ------------------------------
1 1 0 RETAINS_ONLY

1 row selected.




select REC_ID, ACTION_ID, SUBSTR(COMMAND,1,30) AS COMMAND
from USER_ADVISOR_ACTIONS where TASK_NAME = 'anuj_quick_tune'
ORDER BY rec_id, action_id;



select SQL_ID, REC_ID, PRECOST, POSTCOST,(PRECOST-POSTCOST)*100/PRECOST AS PERCENT_BENEFIT
from dba_ADVISOR_SQLA_WK_STMTS
where TASK_NAME = 'anuj_quick_tune'

SQL_ID REC_ID PRECOST POSTCOST PERCENT_BENEFIT
------------- ---------- ---------- ---------- ---------------
3cx27884dw7ar 1 2 2 0

1 row selected.

DBMS_ADVISOR.quick_tune error

ORA-13600, QSM-00794, ORA-06512 when running DBMS_ADVISOR
ORA-13600: error encountered in Advisor

solution
Create the table in other schama rather than SYS, SYSTEM for DBMS_ADVISOR.quick_tune



SQL> show user
USER is "SYS"


SQL> create table anuj(x number)
/
Table created.


SQL> BEGIN
DBMS_ADVISOR.quick_tune(
advisor_name => DBMS_ADVISOR.SQLACCESS_ADVISOR,
task_name => 'anuj_quick_tune',
attr1 => 'SELECT * FROM anuj WHERE x = 88');
END;
/
BEGIN
*
ERROR at line 1:
ORA-13600: error encountered in Advisor
QSM-00794: the statement can not be stored due to a violation of the invalid table reference filter
ORA-06512: at "SYS.PRVT_ACCESS_ADVISOR", line 1808
ORA-06512: at "SYS.WRI$_ADV_SQLACCESS_ADV", line 180
ORA-06512: at "SYS.PRVT_ADVISOR", line 3636
ORA-06512: at "SYS.DBMS_ADVISOR", line 711
ORA-06512: at line 2

Saturday, 25 June 2011

Unix Search a TEXT in file

Unix Search a staring
Search a TEXT in file
search a word in file

find . -type f -exec grep -il "iapi" {} \;

Friday, 24 June 2011

Is Oracle 32-bit or 64-bit and Oracle version ?

Oracle 32-bit or 64-bit ? oracle 32bit or 64bit oracle 32 bit or 64 bit Oracle version [code]
 
-bash-3.2$ sqlplus / as sysdba


apt-rdbms-01.tus.co.uk:APTDB\sys> 

select length(addr)*4 || '-bits' word_length 
from  v$process where rownum<2

-----
             
 
                                                                                                                 SELECT * FROM V$VERSION;

BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
PL/SQL Release 11.2.0.1.0 - Production
CORE    11.2.0.1.0      Production
TNS for Linux: Version 11.2.0.1.0 - Production
NLSRTL Version 11.2.0.1.0 - Production


or



SQL> define
DEFINE _DATE           = "04-AUG-11" (CHAR)
DEFINE _CONNECT_IDENTIFIER = "orcl" (CHAR)
DEFINE _USER           = "SYS" (CHAR)
DEFINE _PRIVILEGE      = "AS SYSDBA" (CHAR)
DEFINE _SQLPLUS_RELEASE = "1102000100" (CHAR)
DEFINE _EDITOR         = "vi" (CHAR)
DEFINE _O_VERSION      = "Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options" (CHAR)
DEFINE _O_RELEASE      = "1102000100" (CHAR)
DEFINE _RC             = "0" (CHAR)




Oracle vesrion


col COMP_NAME format a50
SQL> r
  1* select COMP_NAME ,VERSION,STATUS from dba_registry

COMP_NAME                                          VERSION                        STATUS
-------------------------------------------------- ------------------------------ --------------------------------------------
Oracle Application Express                         4.0.2.00.07                    VALID
OWB                                                11.2.0.1.0                     VALID
OLAP Catalog                                       11.2.0.1.0                     VALID
Spatial                                            11.2.0.1.0                     VALID
Oracle Multimedia                                  11.2.0.1.0                     VALID
Oracle XML Database                                11.2.0.1.0                     VALID
Oracle Text                                        11.2.0.1.0                     VALID
Oracle Expression Filter                           11.2.0.1.0                     VALID
Oracle Rules Manager                               11.2.0.1.0                     VALID
Oracle Workspace Manager                           11.2.0.1.0                     VALID
Oracle Database Catalog Views                      11.2.0.1.0                     VALID
Oracle Database Packages and Types                 11.2.0.1.0                     VALID
JServer JAVA Virtual Machine                       11.2.0.1.0                     VALID
Oracle XDK                                         11.2.0.1.0                     VALID
Oracle Database Java Packages                      11.2.0.1.0                     VALID
OLAP Analytic Workspace                            11.2.0.1.0                     VALID
Oracle OLAP API                                    11.2.0.1.0                     VALID

17 rows selected.



perl $ORACLE_HOME/OPatch/opatch.pl version
Invoking OPatch 11.1.0.6.6

OPatch Version: 11.1.0.6.6

OPatch succeeded.


SELECT PLATFORM_NAME
    FROM V$TRANSPORTABLE_PLATFORM
    WHERE PLATFORM_ID =
       ( SELECT PLATFORM_ID FROM V$DATABASE );


SQL --  !lsnrctl version

LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 04-AUG-2011 09:09:24

Copyright (c) 1991, 2009, Oracle.  All rights reserved.

Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
TNSLSNR for Linux: Version 11.2.0.1.0 - Production
        TNS for Linux: Version 11.2.0.1.0 - Production
        Unix Domain Socket IPC NT Protocol Adaptor for Linux: Version 11.2.0.1.0 - Production
        Oracle Bequeath NT Protocol Adapter for Linux: Version 11.2.0.1.0 - Production
        TCP/IP NT Protocol Adapter for Linux: Version 11.2.0.1.0 - Production,,
The command completed successfully

Thursday, 23 June 2011

To Change the permissions On Unix

To Change the permissions On Unix
Unix permissions
Unix permission



666 : Default permission
002 : - umask value
664 : final permission




#=root


# chmod 777 *.log


u user
g group
o others



Owner Group others Permission
========= ========= ========= ======================
7 (u+rwx) 7 (g+rwx) 7 (o+rwx) read + write + execute
6 (u+wx) 6 (g+wx) 6 (o+wx) write + execute
5 (u+Rx) 5 (g+Rx) 5 (o+Rx) read + execute
4 (u+r) 4 (g+r) 4 (o+r) read only
2 (u+w) 2 (g+w) 2 (o+w) write only
1 (u+x) 1 (g+x) 1 (o+x) execute only


Character equivalents can be used in the chmod command .




#chmod o+rwx *.log
#chmod g+r *.log
#chmod -Rx *.log

chmod -R g+rw hft/



-R recursive

# chown -R oinstall.dba *



Owner Group The others Permission

7 7 7 read + write + execute
6 6 6 write + execute
5 5 5 read + execute
4 4 4 read only
2 2 2 write only
1 1 1 execute only

Oracle Create Soft link

-bash-3.2$ pwd
/usr/lib/oracle/instantclient10_1
-bash-3.2$ ls -ltr libclntsh*
-rwxr-xr-x 1 oracle oinstall 15306239 Dec 7 2005 libclntsh.so.10.1
lrwxrwxrwx 1 oracle dba 17 Jun 22 10:46 libclntsh.so -> libclntsh.so.10.1


ln -s libclntsh.so.10.1 libclntsh.so.11.1

-bash-3.2$ ls -ltr libclntsh*
-rwxr-xr-x 1 oracle oinstall 15306239 Dec 7 2005 libclntsh.so.10.1
lrwxrwxrwx 1 oracle dba 17 Jun 22 10:46 libclntsh.so -> libclntsh.so.10.1
lrwxrwxrwx 1 oracle dba 17 Jun 23 09:28 libclntsh.so.11.1 -> libclntsh.so.10.1
-bash-3.2$

Oracle DBA

anuj blog Archive