Sunday, 21 June 2015

Session specific Optimizer Environment in Oracle


Yesterday there was a need for me to look into what optimizer parameters are set for my particular session only not for the entire database, so below view with the query was really helpful. Try it :-

SQL> select NAME,value  from V$SES_OPTIMIZER_ENV where lower(name) like '%statistics%' and SID=5363;

NAME                                     VALUE
---------------------------------------- -------------------------
statistics_level                         typical
optimizer_use_pending_statistics         false


As per Oracle Doc V$SES_OPTIMIZER_ENV displays the contents of the optimizer environment used by each session. When a new session is first created, it automatically inherits its optimizer environment from the optimizer environment defined at the instance level by V$SYS_OPTIMIZER_ENV. The value of certain parameters can be dynamically modified by issuing an ALTER SESSION statement.

LNS wait on SENDREQ Wait Event


LNS wait on SENDREQ means that redo data has not been written to all ASYNC and SYNC redo transport destinations and that the processes on primary databases are waiting. This is basically a network related wait event which means that tuning the network may be beneficial to remove this wait event. The LNS wait on SENDREQ can happen with either the SYNC or ASYNC LGWR attributes.  When using ASYNC transport mode in Oracle 10g r2 and beyond, Oracle recommends allowing for sufficient I/O bandwidth for LNS read I/Os to the online redo logs of the production database.

As per Oracle Doc LNS wait on SENDREQ means :- Total time spent waiting for redo data to be written to all ASYNC and SYNC redo transport destinations.

There can be multiple ways to tune it :-

1) The very first way to tune is to optimize the network, You can set SDU (SESSION DATA UNIT) parameter within an Oracle Net connect descriptor or globally within the sqlnet.ora. For Data Guard broker configurations configure the DEFAULT_SDU_SIZE parameter in the sqlnet.ora file:

DEFAULT_SDU_SIZE=32767

2) Tuning tNS layer for the tcp.nodelay parameter in the protocol.ora file

3) Get a faster network transport such as dark fibre.

4) Change the size of the online redo logs to make the archived redo log smaller, thereby creating smaller archived redo logs.  This will create more frequent, smaller redo log transports that will complete faster.

Monitoring Synchronous Redo Transport Response Time

The V$REDO_DEST_RESP_HISTOGRAM view contains response time data for each redo transport destination. This response time data is maintained for redo transport messages sent via the synchronous redo transport mode.

The data for each destination consists of a series of rows, with one row for each response time. To simplify record keeping, response times are rounded up to the nearest whole second for response times less than 300 seconds. Response times greater than 300 seconds are round up to 600, 1200, 2400, 4800, or 9600 seconds.

Each row contains four columns: FREQUENCY, DURATION, DEST_ID, and TIME.

The FREQUENCY column contains the number of times that a given response time has been observed. The DURATION column corresponds to the response time. The DEST_ID column identifies the destination. The TIME column contains a timestamp taken when the row was last updated.

The response time data in this view is useful for identifying synchronous redo transport mode performance issues that can affect transaction throughput on a redo source database. It is also useful for tuning the NET_TIMEOUT attribute.

Wait Event "resmgr:cpu quantum"



Wait Event "resmgr:cpu quantum"

The wait event resmgr:cpu quantum is a normal wait event used by the Oracle Resource Manager to control CPU distribution. The resmgr:cpu quantum only occurs when the resource manager is enabled and the resource manage is "throttling" CPU consumption.

You can also detect an overloaded CPU when you see the “resmgr:cpu quantum” event in a top-5 timed event on a AWR or STATSPACK report.

The "resmgr:cpu quantum" only applies when the Oracle resource manager is deployed, and there are other ways to detect an overloaded CPU:

1. - UNIX/Linux - vmstat when the runqueue column (r) exceed the cpu_count for the database.

2. - Windows:  When the processor queue length is greater than zero.

If there 100% CPU Utilization then its important to check Processor Queue Length in the system monitor and task manager. In Windows, it's the "Processor Queue Length", and it's displayed in the system monitor and task manager.

Microsoft notes:

"Processor Queue Length (System) This is the instantaneous length of the processor queue in units of threads. All processors use a single queue in which threads wait for processor cycles.

After a processor is available for a thread waiting in the processor queue, the thread can be switched onto a processor for execution. A processor can execute only a single thread at a time. Note that faster CPUs can handle longer queue lengths than slower CPUs."

"The number of threads in the processor queue. Shows ready threads only, not threads that are running. Even multiprocessor computers have a single queue for processor time; thus, for multiprocessors, you need to divide this value by the number of processors servicing the workload. A sustained processor queue of less than two threads per processor is normally acceptable, depending upon the workload."

Webinar of Oracle Goldengate Architecture with Setup (Karan Dodwal)

Recently  i gave a webinar on Oracle Goldengate Architecture with Setup (Karan Dodwal) and thanks for the audience to attend it and yes the webinar is available at youtube the link is Goldengate_Webinar , the reason for putting it on youtube is that everyone in todays's world watches youtube so why not learn from youtube, so click here  for the link.


Thanks everyone,
Happy Learning
Karan Dodwal (OCM)

Saturday, 20 June 2015

Webinar of Installing Oracle Linux Server

Recently  i gave a Webinar of Installing Oracle Linux Server (Karan Dodwal) and thanks for the audience to attend it and yes the webinar is available at youtube the link is Install_Linux_Oracle the reason for putting it on youtube is that everyone in todays's world watches youtube so why not learn from youtube, so click here  for the link.

Thanks everyone,
Happy Learning
Karan Dodwal (OCM

Thursday, 7 May 2015

Monitoring Index Usage


It would always be good to drop your unused indexes means which are not selected although they may be suffering from too many DML's, so its better to drop them as they are not getting used by select queries and its not good performance that you use them only for DML's. Let us see how to monitor the indexes and get a report :-

To alter an index, your schema must contain the index or you must have the ALTER ANY INDEX system privilege. With the ALTER INDEX statement, you can:

# Rebuild or coalesce an existing index
# Deallocate unused space or allocate a new extent
# Specify parallel execution (or not) and alter the degree of parallelism
# Alter storage parameters or physical attributes
# Specify LOGGING or NOLOGGING
# Enable or disable key compression
# Mark the index unusable
# Make the index invisible
# Rename the index
# Start or stop the monitoring of index usage

Below script will generate commands all you need for an entire schema to monitor the indexes :-

SELECT ' alter index '||index_name||' MONITORING USAGE; ' FROM user_indexes  ;

Index monitoring is started and stopped using the ALTER INDEX syntax shown below.

ALTER INDEX my_index_i MONITORING USAGE;
ALTER INDEX my_index_i NOMONITORING USAGE;

Information about the index usage can be displayed using the V$OBJECT_USAGE view.

In between you will also see below error :-

ERROR at line 1: ORA-00054: resource busy and acquire with NOWAIT specified or timeout expired

This means you cannot alter this index at the moment as there is already some changes going and you cannot get an exlcusive lock on it. Interestingly you should ignore this because this means the index is already being used/changed but selected, so you can do monitoring later for these indexes.


SELECT index_name,
       table_name,
       monitoring,
       used,
       start_monitoring,
       end_monitoring
FROM   v$object_usage
WHERE  index_name = 'IDX1';

The V$OBJECT_USAGE view does not contain an OWNER column so you must to log on as the object owner to see the usage data.

Installing Oracle Goldengate Software

Below we will learn how to Install Oracle Goldengate Software :-

Let us see with ls -ltr and check the zip file of the software :-

[oracle@node4 gg_orcl]$ ls -ltr
total 87192
-rwxrw-rw- 1 oracle oinstall 89186858 Mar  4 16:07 ogg112101_fbo_ggs_Linux_x64_ora11g_64bit.zip
[oracle@node4 gg_orcl]$
[oracle@node4 gg_orcl]$

Lets unzip the file :-

[oracle@node4 gg_orcl]$ unzip ogg112101_fbo_ggs_Linux_x64_ora11g_64bit.zip
Archive:  ogg112101_fbo_ggs_Linux_x64_ora11g_64bit.zip
  inflating: fbo_ggs_Linux_x64_ora11g_64bit.tar
  inflating: OGG_WinUnix_Rel_Notes_11.2.1.0.1.pdf
  inflating: Oracle GoldenGate 11.2.1.0.1 README.txt
  inflating: Oracle GoldenGate 11.2.1.0.1 README.doc

[oracle@node4 gg_orcl]$ tar -xvof *.tar
UserExitExamples/
UserExitExamples/ExitDemo_more_recs/
UserExitExamples/ExitDemo_more_recs/Makefile_more_recs.HPUX
UserExitExamples/ExitDemo_more_recs/Makefile_more_recs.SOLARIS
UserExitExamples/ExitDemo_more_recs/Makefile_more_recs.LINUX
UserExitExamples/ExitDemo_more_recs/Makefile_more_recs.AIX
UserExitExamples/ExitDemo_more_recs/exitdemo_more_recs.vcproj
UserExitExamples/ExitDemo_more_recs/exitdemo_more_recs.c
UserExitExamples/ExitDemo_more_recs/readme.txt
UserExitExamples/ExitDemo_passthru/
UserExitExamples/ExitDemo_passthru/exitdemo_passthru.c
UserExitExamples/ExitDemo_passthru/exitdemopassthru.vcproj
UserExitExamples/ExitDemo_passthru/Makefile_passthru.HPUX
UserExitExamples/ExitDemo_passthru/Makefile_passthru.AIX
UserExitExamples/ExitDemo_passthru/Makefile_passthru.HP_OSS
UserExitExamples/ExitDemo_passthru/Makefile_passthru.LINUX
UserExitExamples/ExitDemo_passthru/readme.txt
UserExitExamples/ExitDemo_passthru/Makefile_passthru.SOLARIS
UserExitExamples/ExitDemo_lobs/
UserExitExamples/ExitDemo_lobs/exitdemo_lob.c
UserExitExamples/ExitDemo_lobs/Makefile_lob.HPUX
UserExitExamples/ExitDemo_lobs/Makefile_lob.SOLARIS
UserExitExamples/ExitDemo_lobs/Makefile_lob.AIX
UserExitExamples/ExitDemo_lobs/exitdemo_lob.vcproj
UserExitExamples/ExitDemo_lobs/Makefile_lob.LINUX
UserExitExamples/ExitDemo_lobs/readme.txt
UserExitExamples/ExitDemo_pk_befores/
UserExitExamples/ExitDemo_pk_befores/Makefile_pk_befores.AIX
UserExitExamples/ExitDemo_pk_befores/Makefile_pk_befores.LINUX
UserExitExamples/ExitDemo_pk_befores/exitdemo_pk_befores.c
UserExitExamples/ExitDemo_pk_befores/Makefile_pk_befores.HPUX
UserExitExamples/ExitDemo_pk_befores/exitdemo_pk_befores.vcproj
UserExitExamples/ExitDemo_pk_befores/Makefile_pk_befores.SOLARIS
UserExitExamples/ExitDemo_pk_befores/readme.txt
UserExitExamples/ExitDemo/
UserExitExamples/ExitDemo/exitdemo.vcproj
UserExitExamples/ExitDemo/Makefile_exit_demo.SOLARIS
UserExitExamples/ExitDemo/Makefile_exit_demo.HP_OSS
UserExitExamples/ExitDemo/exitdemo.c
UserExitExamples/ExitDemo/Makefile_exit_demo.LINUX
UserExitExamples/ExitDemo/exitdemo_utf16.c
UserExitExamples/ExitDemo/Makefile_exit_demo.HPUX
UserExitExamples/ExitDemo/Makefile_exit_demo.AIX
UserExitExamples/ExitDemo/readme.txt
bcpfmt.tpl
bcrypt.txt
cfg/
cfg/password.properties
cfg/MPMetadataSchema.xsd
cfg/jps-config-jse.xml
cfg/ProfileConfig.xml
cfg/mpmetadata.xml
cfg/Config.properties
chkpt_ora_create.sql
cobgen
convchk
db2cntl.tpl
ddl_cleartrace.sql
ddl_ddl2file.sql
ddl_disable.sql
ddl_enable.sql
ddl_filter.sql
ddl_nopurgeRecyclebin.sql
ddl_ora10.sql
ddl_ora10upCommon.sql
ddl_ora11.sql
ddl_ora9.sql
ddl_pin.sql
ddl_purgeRecyclebin.sql
ddl_remove.sql
ddl_session.sql
ddl_session1.sql
ddl_setup.sql
ddl_status.sql
ddl_staymetadata_off.sql
ddl_staymetadata_on.sql
ddl_trace_off.sql
ddl_trace_on.sql
ddl_tracelevel.sql
ddlcob
defgen
demo_more_ora_create.sql
demo_more_ora_insert.sql
demo_ora_create.sql
demo_ora_insert.sql
demo_ora_lob_create.sql
demo_ora_misc.sql
demo_ora_pk_befores_create.sql
demo_ora_pk_befores_insert.sql
demo_ora_pk_befores_updates.sql
dirjar/
dirjar/xmlparserv2.jar
dirjar/fmw_audit.jar
dirjar/jps-internal.jar
dirjar/org.springframework.jdbc-3.0.0.RELEASE.jar
dirjar/org.springframework.context-3.0.0.RELEASE.jar
dirjar/jps-upgrade.jar
dirjar/oraclepki.jar
dirjar/org.springframework.transaction-3.0.0.RELEASE.jar
dirjar/xstream-1.3.jar
dirjar/jsr250-api-1.0.jar
dirjar/org.springframework.beans-3.0.0.RELEASE.jar
dirjar/ldapjclnt11.jar
dirjar/spring-security-cas-client-3.0.1.RELEASE.jar
dirjar/jps-manifest.jar
dirjar/org.springframework.aspects-3.0.0.RELEASE.jar
dirjar/identityutils.jar
dirjar/org.springframework.aop-3.0.0.RELEASE.jar
dirjar/jacc-spi.jar
dirjar/jmxremote_optional-1.0-b02.jar
dirjar/slf4j-log4j12-1.4.3.jar
dirjar/jps-api.jar
dirjar/slf4j-api-1.4.3.jar
dirjar/identitystore.jar
dirjar/jps-unsupported-api.jar
dirjar/osdt_xmlsec.jar
dirjar/org.springframework.orm-3.0.0.RELEASE.jar
dirjar/jagent.jar
dirjar/commons-codec-1.3.jar
dirjar/jps-ee.jar
dirjar/spring-security-taglibs-3.0.1.RELEASE.jar
dirjar/log4j-1.2.15.jar
dirjar/osdt_core.jar
dirjar/spring-security-acl-3.0.1.RELEASE.jar
dirjar/xpp3_min-1.1.4c.jar
dirjar/spring-security-web-3.0.1.RELEASE.jar
dirjar/spring-security-core-3.0.1.RELEASE.jar
dirjar/spring-security-config-3.0.1.RELEASE.jar
dirjar/jps-mbeans.jar
dirjar/org.springframework.test-3.0.0.RELEASE.jar
dirjar/jdmkrt-1.0-b02.jar
dirjar/jps-common.jar
dirjar/org.springframework.web-3.0.0.RELEASE.jar
dirjar/jps-patching.jar
dirjar/jps-wls.jar
dirjar/commons-logging-1.0.4.jar
dirjar/org.springframework.expression-3.0.0.RELEASE.jar
dirjar/org.springframework.instrument-3.0.0.RELEASE.jar
dirjar/monitor-common.jar
dirjar/osdt_cert.jar
dirjar/org.springframework.asm-3.0.0.RELEASE.jar
dirjar/org.springframework.context.support-3.0.0.RELEASE.jar
dirjar/org.springframework.core-3.0.0.RELEASE.jar
dirprm/
dirprm/jagent.prm
emsclnt
extract
freeBSD.txt
ggMessage.dat
ggcmd
ggsci
help.txt
jagent.sh
keygen
libantlr3c.so
libdb-5.2.so
libgglog.so
libggrepo.so
libicudata.so.38
libicui18n.so.38
libicuuc.so.38
libxerces-c.so.28
libxml2.txt
logdump
marker_remove.sql
marker_setup.sql
marker_status.sql
mgr
notices.txt
oggerr
params.sql
prvtclkm.plb
pw_agent_util.sh
remove_seq.sql
replicat
retrace
reverse
role_setup.sql
sequence.sql
server
sqlldr.tpl
tcperrs
ucharset.h
ulg.sql
usrdecs.h
zlib.txt

[oracle@node4 gg_orcl]$ ./ggsci

Oracle GoldenGate Command Interpreter for Oracle
Version 11.2.1.0.1 OGGCORE_11.2.1.0.1_PLATFORMS_120423.0230_FBO
Linux, x64, 64bit (optimized), Oracle 11g on Apr 23 2012 08:32:14

Copyright (C) 1995, 2012, Oracle and/or its affiliates. All rights reserved.



GGSCI (node4.oracle.com) 1> Create Subdirs

Creating subdirectories under current directory /u01/app/oracle/gg_orcl

Parameter files                /u01/app/oracle/gg_orcl/dirprm: already exists
Report files                   /u01/app/oracle/gg_orcl/dirrpt: created
Checkpoint files               /u01/app/oracle/gg_orcl/dirchk: created
Process status files           /u01/app/oracle/gg_orcl/dirpcs: created
SQL script files               /u01/app/oracle/gg_orcl/dirsql: created
Database definitions files     /u01/app/oracle/gg_orcl/dirdef: created
Extract data files             /u01/app/oracle/gg_orcl/dirdat: created
Temporary files                /u01/app/oracle/gg_orcl/dirtmp: created
Stdout files                   /u01/app/oracle/gg_orcl/dirout: created


GGSCI (node4.oracle.com) 2> dblogin userid krishna, password some_password
Successfully logged into database.