Thursday, March 29, 2012

Oracle Parallel Execution

1. What is Oracle Parallel Execution?

Parallel Execution allows Oracle to perform specific database actions in parallel.

2. Which sub types of Parallel Execution exist?

The following types of Parallel Execution are most important:

Parallel Query

Parallel Query allows to parallelize certain components of selections, e.g.:

Full table scans
Index fast full scans
Access to inner tables of nested loop joins
Parallel DML

Parallel DML allows to parallelize DML operations:

UPDATE
DELETE
INSERT
Parallel DDL

Parallel DDL allows to parallelize DDL operations, e.g. :

CREATE INDEX
ALTER INDEX REBUILD
CREATE TABLE AS SELECT

Parallel Recovery

Parallel Recovery can be used to parallelize recovery activities:

RECOVER DATABASE

The most important Parallel Execution type is Parallel Query. Therefore this note focuses on the Parallel Query type. Nevertheless the technical details apply in the same way also to the other Parallel Execution types.

3. What are the advantages of Parallel Execution?

Based on Parallel Execution you are able to use more system resources like CPU or I/O at the same time for a specific operation. As a consequence the total runtime can significantly decrease.

4. What are restrictions and disadvantages of Parallel Execution?

The following disadvantages are possible:

Resource bottlenecks

Executing an operation in parallel involves increased resource usage (e.g. CPU or I/O). In the worst case a bottleneck situation can be the consequence and the whole system performance is impacted.

High parallelism in case of DEFAULT degree and many CPUs

If a Parallel Execution is performed with DEFAULT degree, a very high parallelism is possible. In order to avoid this it is usually recommended not to use the DEFAULT degree.


Wrong CBO decisions

Activated Parallel Query can significantly impact the calculations of the Cost Based Optimizer (see note 750631). In the worst case a good (sequential) index access can turn into a long running (parallel) full table

scan.

No RBO support

Parallel Query requires the CBO because the Rule Based Optimizer isn't able to handle it. If the CBO is used for an access on tables without statistics, this can cause performance problems.


Parallel DDL activates segment parallelism

If a parallel DDL operation like ALTER INDEX REBUILD PARALLEL is performed, the parallelism degree for the index remains even after the DDL operation is finished. As a consequence unintentionally parallel query

might be used. In order to avoid problems you have to make sure that you reset the parallelism degree of the concerned segments to 1 after the DDL operation. The BR*TOOLS perform this activity automatically after

parallelized DDL operations.

Wrong result sets with 10g

Due to the Oracle bug described in note 985118 it is possible that Parallel Executions return a wrong result set.

Insufficient explain information

With older SAP releases parallel query is not taken into account in the explain functionality in transaction ST04 or ST05 (see note 723879). As a consequence misconceptions and irritations are possible.

Shared pool allocation

Parallel query can consume significant amounts of shared pool memory for communication purposes. Particularly in the case of high values for PARALLEL_MAX_SERVERS and

PARALLEL_EXECUTION_MESSAGE_SIZE up to several GB of shared pool memory can be allocated. A consequence can be ORA-04031 errors (see note 869006).

No parallel DML with IOTs

It is not possible to use parallel DML in combination with (unpartitioned) Index Organized Tables (IOTs).

5. How is Parallel Execution performed on a technical layer?

The following processes are used to perform a Parallel Execution:

Parallel Execution Coordinator

The Parallel Execution Coordinator (later on referred to as "coordinator") is the control process that distributes the work across the Parallel Execution Slaves.

Up to Oracle 9i the coordinator splits SQL statements into smaller pieces (in terms of the working set) and passes the "smaller" SQL commands to the Parallel Execution Slaves. Typical SQL statements that

are transformed by the coordinator look like:

SELECT /*+ CIV_GB */ A1.C0,AVG(SYS_OP_CSR(A1.C1,0)), MAX(SYS_OP_CSR(A1.C1,1)) FROM :Q490001 A1 GROUP BY A1.C0
SELECT /*+ PIV_GB */ A1.C1 C0,SYS_OP_MSR(AVG(A1.C0),MAX(A1.C0)) C1 ...
... /*+ ORDERED NO_EXPAND USE_HASH(A3) */ ...
... /*+ Q354359000 NO_EXPAND ROWID(A4) */ ...
... PX_GRANULE(0, BLOCK_RANGE, DYNAMIC) ...
SELECT /*+ PIV_SSF */ SYS_OP_MSR(MAX(A1.C0)) FROM ...
As of 10g the original SQL statement is passed to the Parallel Execution Slave without any transformation.

Parallel Execution Slaves (in the following named "slaves")

There are two types of Parallel Execution Slaves:

Producers
The producers read the source data and pass it to the consumers or the coordinators.

Consumers
The consumers take the data from the producers and process it. Consumers are only needed if the data from the producers needs to be post-processed (e.g. sorted).

The communication and data transfer between the processes is based on queues. The communication structures are part of the shared pool:

PX msg pool

Communication area for the parallel query processes
Size depends mainly on PARALLEL_EXECUTION_MESSAGE_SIZE, PARALLEL_MAX_SERVERS and the actually used parallel query slaves
PX subheap

Memory structure with additional parallel query related information
Usually small compared to "PX msg pool"
Blocks that are read via Parallel Execution are always read directly from disk bypassing the Oracle buffer pool. For more information about this "direct path" operation see the "direct path read" section in note

619188.

In order to make sure that the most recent data is read from disk a segment specific checkpoint is performed before the "direct path read" operations are started.

6. Which parameters exist in relation to Parallel Execution?

The following Oracle parameters are most important with regards to Parallel Execution:

CPU_COUNT

CPU_COUNT is a parameter that reflects the number of CPUs on the database server. It is used for several Oracle internal purposes and also influences the DEFAULT parallelism used by Oracle (see below).

As CPU_COUNT influences Oracle at a lot of locations, the default value should not be changed.

PARALLEL_EXECUTION_MESSAGE_SIZE

This parameter determines the size of the communication buffer between the differen Parallel Execution processes.

In order to avoid a bottleneck it's recommended to set this parameter to 16384.

PARALLEL_INSTANCE_GROUP

This parameter can be used in RAC environments in order to restrict Parallel Executions to a sub set of the existing RAC instances.

PARALLEL_MAX_SERVERS

With this parameter the maximum number of simultaneously active slave processes can be specified. If more slaves are requested at a certain time the requests are downgraded and a smaller parallelism is

used.

SAP recommends setting this parameter to 10 times the number of CPUs available for the Oracle database in OLAP and Oracle 10g environments.

PARALLEL_MIN_SERVERS

This parameter specifies how many slave processes are created during database startup. If more slaves are needed, they are created on demand.

It's recommended to keep this parameter on the default of 0 in order to avoid unnecessarily started slave processes.

PARALLEL_THREADS_PER_CPU

This parameter influences the DEFAULT parallelism degree (see below).

In order to avoid overload situations with DEFAULT parallelism it's recommended to set this parameter to 1.

PARALLEL_ADAPTIVE_MULTI_USER

When this parameter is set to TRUE (what is default for Oracle 10g) parallel executions may be downgraded by Oracle even before PARALLEL_MAX_SERVERS is reached in order to limit the system load. If

you need to guarantee maximum parallelization (like during reorganizations or system copies) it is advisable to set this parameter to FALSE. During normal operation the value TRUE should be okay because resource

bottlenecks can be avoided.

7. How are activation and degree of parallelism determined?

The following points have to be taken into account in order to determine if and to what extent Parallel Query is used:

The operation must be parallelizable (e.g. full table scan, scan of partitioned index). An index range scan on a non-partitioned index e.g. can't be performed in parallel.

The parallelism must be activated on segment or on statement level.

Segment level
Parallelism on segment level can be activated with the following command:
ALTER TABLE PARALLEL ;
ALTER INDEX PARALLEL ;

In order to check the parallelism for a certain segment, you can use the following selection:
SELECT DEGREE FROM DBA_TABLES WHERE TABLE_NAME = '';
SELECT DEGREE FROM DBA_INDEXES WHERE INDEX_NAME = '';

Statement level
On SQL statement level the following hint can be used to activate parallelism (see note 772497):
PARALLEL(, )

If is a positive number, up to producers and consumers can be used for a parallel query (-> 2 * slaves).

If DEFAULT is specified for , CPU_COUNT * PARALLEL_THREADS_PER_CPU producers and CPU_COUNT * PARALLEL_THREADS_PER_CPU consumers can be used for a parallel query.

If the PARALLEL_MAX_SERVERS limit is exceeded taking into account all simultaneously active Parallel Executions, the degree of parallelism is reduced.

8. To what extent does SAP use parallelism on segment and statement level?

Per default no segments with activated parallelism are delivered by SAP.

Parallelism on statement level (-> PARALLEL hint) is frequently used in BW environments (e.g. in case of aggregate rollup). In OLTP environments the PARALLEL hint is used only in exceptional situations.

9. How can segments with activated parallelism be determined?

With the following selection all tables and indexes can be determined that have a parallelism degree > 1 or DEFAULT:
SELECT
TABLE_NAME SEGMENT_NAME,
DEGREE,
INSTANCES
FROM DBA_TABLES
WHERE
OWNER LIKE 'SAP%' AND
(DEGREE != ' 1' OR INSTANCES != ' 1')
UNION
SELECT
INDEX_NAME SEGMENT_NAME,
SUBSTR(DEGREE, 1, 10) DEGREE,
SUBSTR(INSTANCES, 1, 10) INSTANCES
FROM DBA_INDEXES
WHERE
OWNER LIKE 'SAP%' AND
INDEX_TYPE != 'LOB' AND
(DEGREE != '1' OR INSTANCES NOT IN ('0', '1'));

10. How can the parallelism degree of segments be modified?

With the following commands the parallelism for a table or index can be deactivated:
ALTER TABLE PARALLEL (DEGREE 1 INSTANCES 1);
ALTER INDEX PARALLEL (DEGREE 1 INSTANCES 1);

In order to set the parallel degree to a certain value, you can use:
ALTER TABLE PARALLEL ;
ALTER INDEX PARALLEL ;

11. How can you determine to what extent the parallelism is downgraded?

The following selection returns how many Parallel Executions are downgraded to what extent:
SELECT NAME, VALUE FROM V$SYSSTAT
WHERE NAME LIKE 'Parallel operations%';

12. Which wait events exist with regards to Parallel Execution?

The following are the main wait events in the area of Parallel Execution (see note 619188 for more information on Oracle wait events). As it is difficult to distinguish between idle events and busy events in the area of

parallel execution, these two types are not distinguished.

PX Idle Wait

A slave waits for acquiration by a coordinator. This is a real idle event.

PX Deq: Execute Reply

The coordinator waits for slaves to finish their work.

PX Deq: Table Q Normal

A consumer waits for data from its producer.

PX Deq: Execution Msg

A slave waits for further instructions from the coordinator.

PX Deq Credit: send blkd

A producer wants to send something to its consumer, but the consumer has not finished the previous work, yet. The same is valid for a slave that want to send something to its coordinator.

In order to tune this wait event you have to check why the consumer / coordinator is not able to process the producer data fast enough. For example deactivated parallelism for DML operations can result in high "PX

Deq Credit: send blkd" waits for parallelized activities containing DML operations (e.g. INSERT ... SELECT). In this case "ALTER SESSION ENABLE PARALLEL DML" can optimize the parallelization.

If an SAP process fetches record by record from the database using parallel query and performs some processing on ABAP side in between, parallel execution slaves wait for "PX Deq Credit: send blkd" during the

ABAP processing. In this case huge wait times for this wait event and huge elapsed times for the SQL statement can be seen although the real execution time on database side is very small. In this scenario "PX Deq

Credit: send blkd" can be treated as an idle event.

PX qref latch

A consumer has to wait for its communication queue to be available. Make sure that PARALLEL_EXECUTION_MESSAGE_SIZE is set to 16384 in order to avoid many small communications and reduce this kind of

contention.

Another possible reason for "PX qref latch" waits is the fact that the consumer (or coordinator) processes the data slower than the producer generates it. In this case further optimization is hardly possible.

PX Deq: Signal ACK
PX Deq: Join ACK
PX Deq Credit: need buffer

These wait events are related to process communication: The coordinator waits for an acknowledgement of a control message ("PX Deq: Signal ACK") or join request ("PX Deq: Join ACK") from a slave or processes

need a queue buffer in order to send data ("PX Deq Credit: need buffer"). It is normal that these events occur (and so Oracle treats them partially as idle events), but if you have doubts that too much time is spent for

communicating, you should check for overall resource bottlenecks (e.g. CPU) and unnecessary parallelization of small tasks.

PX Deq: Parse Reply

The coordinator waits until the slaves have parsed their SQL statements. In case of increased waits for "PX Deq: Parse Reply" you should check if the shared pool is sized sufficiently (note 789011) and if there are

some parallel query SQL statements with a high parse time (note 712624 (24)).

reliable message

The coordinator waits for a reply from another instance in RAC environments. This can e.g. happen if Oracle parameters are set system wide using ALTER SYSTEM.

To a minor extent waits for "reliable message" can also show up in non RAC systems.

latch free (for "query server process" latch)

The "query server process" latch is allocated if an additional slaves are created. This is necessary if more slaves then defined with PARALLEL_MIN_SERVERS are needed. In order to optimize this kind of latch wait

you should check on the one hand side if Parallel Execution is activated by accident (e.g. on segment level) and switch it off in this case. Alternatively you can consider setting PARALLEL_MIN_SERVERS to a higher

value.

13. Where can I find more information about Parallel Execution activites on the system?

The following selection from V$PX_SESSION can be used to monitor the current activities of Parallel Execution processes:
SELECT
PS.SID,
DECODE(SERVER_SET, NULL, 'COORDINATOR', 1, ' CONSUMER',
' PRODUCER') ROLE,
DECODE(SW.WAIT_TIME, 0, SW.EVENT, 'CPU') ACTION,
SQ.SQL_TEXT
FROM
V$PX_SESSION PS,
V$SESSION_WAIT SW,
V$SQL SQ,
V$SESSION S,
AUDIT_ACTIONS AA
WHERE
PS.SID = SW.SID AND
S.SID = PS.SID AND
S.SQL_ADDRESS = SQ.ADDRESS (+) AND
AA.ACTION = S.COMMAND
ORDER BY PS.QCSID, NVL(PS.SERVER#, 0), PS.SERVER_SET;

In addition the following Parallel Execution related views exist:

V$PQ_SYSSTAT

The view V$PQ_SYSSTAT contains general information about Parallel Execution activities like number of Parallel Queries, Parallel DML and Parallel DDL or currently active sessions.

V$PQ_SLAVE

This view contains information about the existing parallel query slaves.

V$PQ_TQSTAT

Statistics for different parallel queries (separated by DFO_NUMBER)

14. How can the progress of a parallelized full table scan be monitored?

Create the following fuction in the schema of a user who has the the the privileges
grant analyze any to ;
grant select any table to ;

directly (not via role) granted. Usually not even the user 'SYS' has these privileges granted directly.
create or replace function sap_fts_progress_parallel
(owner varchar2, tab_name varchar2, sess number, blocks number)
RETURN char IS
stat_nr number;
tot_blk number;
unu_blk number;
dummy number;
query_act number;
perc number;
hwm number;
begin
if blocks=-1 then
dbms_space.unused_space(owner, tab_name, 'TABLE', tot_blk,
dummy, unu_blk, dummy, dummy, dummy, dummy, dummy);
hwm := tot_blk-unu_blk;
else
hwm := blocks;
end if;
select statistic# into stat_nr from v$statname
where name='physical reads direct';

select count(1) into query_act from v$px_sesstat
where statistic#=stat_nr
and qcsid=decode(sign(sess),1,sess,qcsid);

if query_act=0 then
return 'Query not active';
else
select sum(value)/decode(hwm,0,1,hwm)*100 into perc
from v$px_sesstat where statistic#=stat_nr
and sid <>qcsid
and qcsid=decode(sign(sess),1,sess,qcsid);
return to_char(perc,'999.9')||'% of '||to_char(hwm)||' Blocks';
end if;

end;
/

Doublecheck if the character '|' is copied when you cut and paste the function definition.

Execute the function with
select sap_fts_progress_parallel('','',,-1) from
dual;

when your parallel query is running to get the percentual progress and the total number of blocks to be read (example output: '43.7% of 6973 Blocks'). .
is the object on which the query runs.

specifies the session id which initiated the query. For larger tables you can increase performance if you specify the total number of blocks given back from the first query at the second and all further executions:
select sap_fts_progress_parallel('','
',,)
from dual;

If you are sure that there is no other parallel query running concurrently then you can also set equal '-1'. If - against the prerequisite - another query runs then the percentual value is undefined.

15. Which error can show up in relation to Parallel Execution?

The following errors are important in the area of Parallel Execution:

ORA-12801: error signaled in parallel query server

This error indicates that a parallel query process had to terminate due to an error situation. As described in note 636475, the ORA-12801 is a secondary Oracle error code. You have to check for the real error message

that accompanies the ORA-12801 error.

ORA-12805: parallel query server died unexpectedly

This error indicates that a parallel query process terminated in a hard way. In this case you have to analyze trace files and the alert log for more information.

16. How does the INSTANCES setting influence the parallelism?

The INSTANCES storage parameter is mainly intended for RAC environments and has a similar effect like the PARALLEL storage parameter. In order to avoid confusion it is recommended not to use the INSTANCES

parameter setting.

17. How can parallelism be activated on session level?

You can enable the different types of parallelism on session level using: ALTER SESSION ENABLE PARALLEL QUERY;
ALTER SESSION ENABLE PARALLEL DDL;
ALTER SESSION ENABLE PARALLEL DML;

While PARALLEL QUERY and PARALLEL DDL are activated per default, PARALLEL DML has to be activated explicitly if required. This can e.g. be useful in case of parallelized BRSPACE online reorganizations. Per

default only the reading of the source table is parallelized while the writing into the target table is done sequentially. By activating PARALLEL DML the writing can be parallelized.

Additionally it is also possible to force parallelism on session level even if no PARALLEL hint or segment parallelism is used:
ALTER SESSION FORCE PARALLEL QUERY PARALLEL ;
ALTER SESSION FORCE PARALLEL DDL PARALLEL ;
ALTER SESSION FORCE PARALLEL DML PARALLEL ;


Wednesday, March 28, 2012

Role Creation Using Network Link

BEGIN
FOR cur_rec IN (SELECT role
FROM dba_roles@lnk_previousyearbalance) LOOP
BEGIN
EXECUTE IMMEDIATE 'CREATE ROLE ' || cur_rec.role ;
EXCEPTION
WHEN OTHERS THEN
NULL;
END;
END LOOP;
END;
/


BEGIN
FOR cur_rec IN (SELECT grantee,privilege
FROM DBA_SYS_PRIVS@lnk_previousyearbalance where grantee not in ('SYS','SYSTEM','SYSMAN','TSMSYS','WMSYS','RECOVERY_CATALOG_OWNER','RESOURCE','OUTLN','ORACLE_OCM','OEM_MONITOR','OEM_ADVISOR','MGMT_USER','IMP_FULL_DATABASE','EXP_FULL_DATABASE','DBA','CONNECT','AQ_ADMINISTRATOR_ROLE','DBSNMP','SCHEDULER_ADMIN')) LOOP
BEGIN
EXECUTE IMMEDIATE ('Grant ' || cur_rec.privilege || ' to ' || cur_rec.grantee );
EXCEPTION
WHEN OTHERS THEN
NULL;
END;
END LOOP;
END;
/

BEGIN
FOR cur_rec IN (SELECT grantee,privilege,table_name
FROM dba_tab_privs@lnk_previousyearbalance Where Grantor='LDBO') LOOP
BEGIN
EXECUTE IMMEDIATE 'Grant ' || cur_rec.privilege || ' on ' || cur_rec.table_name || ' to ' || cur_rec.grantee ;
EXCEPTION
WHEN OTHERS THEN
NULL;
END;
END LOOP;
END;
/

BEGIN
FOR cur_rec IN (SELECT grantee,privilege,table_name,column_name
FROM dba_col_privs@lnk_previousyearbalance Where Grantor='LDBO') LOOP
BEGIN
EXECUTE IMMEDIATE 'Grant '|| cur_rec.PRIVILEGE || '('|| cur_rec.COLUMN_NAME ||') on '|| cur_rec.TABLE_NAME || ' to ' || cur_rec.GRANTEE ;
EXCEPTION
WHEN OTHERS THEN
NULL;
END;
END LOOP;
END;
/


BEGIN
FOR cur_rec IN (SELECT grantee,granted_role
FROM dba_role_privs@lnk_previousyearbalance Where Grantee!='SYSTEM' and Grantee!='SYS' and Grantee!='DBSNML' and Grantee!='REPADMIN') LOOP
BEGIN
EXECUTE IMMEDIATE 'Grant '|| cur_rec.granted_role || ' to ' || cur_rec.GRANTEE ;
EXCEPTION
WHEN OTHERS THEN
NULL;
END;
END LOOP;
END;
/

User Creation using Network Link

------------Create profile
BEGIN
FOR cur_rec IN (SELECT distinct profile,Resource_name,limit
FROM dba_profiles@lnk_previousyearbalance where profile!='DEFAULT') LOOP
BEGIN
EXECUTE IMMEDIATE 'Create profile '|| cur_rec.profile ||' Limit '|| cur_rec.Resource_name ||' '|| cur_rec.Limit ;
EXCEPTION
WHEN OTHERS THEN
NULL;
END;
END LOOP;
END;
/

------------Alter profile
BEGIN
FOR cur_rec IN (SELECT distinct profile,Resource_name,limit
FROM dba_profiles@lnk_previousyearbalance where profile!='DEFAULT' and Limit!='DEFAULT') LOOP
BEGIN
EXECUTE IMMEDIATE 'Alter profile '|| cur_rec.profile ||' Limit '|| cur_rec.Resource_name ||' '|| cur_rec.Limit ;
EXCEPTION
WHEN OTHERS THEN
NULL;
END;
END LOOP;
END;
/

------------Create User

BEGIN
FOR cur_rec IN (SELECT username,password,default_tablespace,temporary_tablespace,profile
FROM dba_users@lnk_previousyearbalance where username!='SYSTEM' and Username!='SYS' and Username!='DBSNMP' and Username!='REPADMIN') LOOP
BEGIN
EXECUTE IMMEDIATE 'create user ' || cur_rec.username || ' identified by values ' || '''' || cur_rec.password || '''' || ' default tablespace ' || cur_rec.default_tablespace || ' temporary tablespace ' || cur_rec.temporary_tablespace || ' profile ' || cur_rec.profile;
EXCEPTION
WHEN OTHERS THEN
NULL;
END;
END LOOP;
END;
/


Common Error And Solutions

1. Oracle Memory Sizing

RAM = 4GB

Databases =4

-----------For Old Year

Connect to old year database SQLPLUSW sys/oracle@apx0910srv AS SYSDBA

Create pfile from spfile;

show parameter sga

show parameter pga

alter system set sga_target=500M;

alter system set sga_max_size=500M scope=spfile;

alter system set pga_aggregate_target=100M;

shutdown immediate

startup

----------------For Current and Last Year

Connect to old year database SQLPLUSW sys/oracle@apx1213srv AS SYSDBA

SQLPLUSW sys/oracle@apx1112srv AS SYSDBA

Create pfile from spfile;

show parameter sga

show parameter pga

alter system set sga_target=800M;

alter system set sga_max_size=800M scope=spfile;

alter system set pga_aggregate_target=300M;

shutdown immediate

startup

Note1: For 32 bit server, Max Oracle Memory Limit 2*32bits (1.7GB)

Don't give more that 1.5 gb to sga otherwise oracle will not started

Note2: Please disable all OracleJobScheduler, OracleDBConsole services from services.msc

Note3: Stop Archiving for old year databases

2. Change Utl_file_dir location

create pfile from spfile;

Alter system set utl_file_dir='D:\ldoutput' Scope=spfile ;

shut immediate

startup

3. How to set default tablespace as USR ?

select * from database_properties where property_name like '%TABLESPACE';

Alter Database default tablespace "USR" ;

4. At the time of LD Login it shows error message "Oracle Not Available" or Shared Memory Realm does not exist ?

Manually start database

sqlplusw sys@apx1213srv as sysdba

startup

5.for ld digital

sqlplusw sys@apx1213srv as sysdba

CREATE DIRECTORY LDDGITAL AS 'd:\ldoutput\Lddigital';

grant read, write on directory LDDIGITAL to ldbo;

6. If any entry of LISTENER_APX1213 in tnsnames.ora then remove it.

show parameter listener

create pfile from spfile;

alter system set local_listener='' scope=spfile;

shut immediate

start

7. if listener shows error

run listener services from windows command prompt to view right status

lsnrctl status

lsnrctl stop

lsnrctl start

8. Master Transmission Performance

1) delete from CLIENTSCANNEDIMAGE; before master transmission for better performance

2) create table from sql

3) later imp clientscannedimage table

exp ldbo@ldbo@apx1112srv file='d:\expdp1112\tblclientscan.dmp' log='d:\expdp1112\tblclientscan.log' TABLES= CLIENTSCANNEDIMAGE

imp ldbo@ldbo@apx1213srv file='d:\expdp1112\tblclientscan.dmp' log='d:\expdp1112\tblclientscan1.log'

9. if Space Issue, Stop Archiving at time of import or other long insert / update / transmission process. Later enable

Disable Archiving

sqlplusw sys@apx1213srv as sysdba

shut immediate

startup mount

alter database noarchivelog;

alter database open;

Enable Archiving

shut immediate

startup mount

alter database archivelog;

alter database open;

10. unable to extend <> segment by <> in tablespace USR

ALTER TABLESPACE USR

ADD DATAFILE 'D:\APXD1213\USERS2.ORA' SIZE 2048M

AUTOEXTEND ON

NEXT 1024M

MAXSIZE unlimited;

11. ora-01536 space quota exceed

ALTER USER LDBO QUOTA UNLIMITED on USR;

ALTER USER LDBO QUOTA UNLIMITED on INDX;

12. ORA-38029 object statistics are locked

select 'exec DBMS_STATS.UNLOCK_TABLE_STATS('''||owner||''','''||table_name||''');' from dba_tab_statistics where stattype_locked is not null and owner not in ('SYS','SYSTEM');

RUN THE OUTPUT RESULT

13. ORA-25153 Temporary Tablespace is Empty

ALTER TABLESPACE temporary ADD tempfile 'D:\APX1213D\TEMP01.ORA' SIZE 1000M REUSE AUTOEXTEND ON NEXT 500M MAXSIZE unlimited;

14. ORA-20014: %s Brokerage cannot be Run. ~-27477~ORA-27477: "LDBO.C_BSENM1112177_J" already exists

BEGIN

DBMS_SCHEDULER.DROP_JOB (

job_name => 'C_BSENM1112177_J');

END;

/

15. Tablespace, Datafiles Details

select tablespace_name,block_size,INITIAL_EXTENT/1024,MAX_EXTENTS/1024/1024/1024,segment_space_management,bigfile from dba_tablespaces;

select file_name,tablespace_name,bytes/1024/1024,autoextensible,increment_by from dba_temp_files;

select file_name,tablespace_name,bytes/1024/1024,MAXbytes/1024/1024,autoextensible,increment_by from dba_data_files;

16. Partitioned Table Details

select table_name from user_part_tables;

select name,column_name from user_part_key_columns;

select * from user_tab_partitions;

17.

If following ODBC error (Mostly occur at Large DB / Partitioned Table Clients)

Most Critical Error In Oracle ORA-00600

[Microsoft][ODBC driver for Oracle][Oracle]ORA-00600: internal error code, arguments: [15735], [2168], [2152], [], [], [], [], []

solution:

sqlplusw sys@apx1213srv as sysdba

create pfile from spfile;

show parameter parallel_automatic_tuning

alter system set parallel_automatic_tuning=TRUE scope=spfile;

alter system set parallel_execution_message_size=4096 scope=spfile;

shut immediate

startup

18. Enable / Disable Trigger

Alter Trigger Enable ;

Alter Trigger Disable ;

19. Enable / Disable Constraint

Alter Table Enable constraint ;

Alter Table Disable constraint ;

20. ORA-14402 updating partition key column would cause a partition change

ALTER TABLE enable row movement;

21. COMPILE OBJECT ERROR

ORA-02019: connection description for remote database not found

TABLE VIEW DOES NOT EXIST

ADD DATABASE LINK

CREATE PUBLIC DATABASE LINK "LNK_RAKSHAK"

CONNECT TO "LDBO" IDENTIFIED BY password USING 'apx1213srv';

CREATE PUBLIC DATABASE LINK "LNK_CCM"

CONNECT TO "LDBO" IDENTIFIED BY password USING 'apx1213srv';

CREATE DATABASE LINK "LNK_DIGITAL"

CONNECT TO "LDBO" IDENTIFIED BY password USING 'apx1213srv';

Saturday, March 24, 2012

PGA Top Consumer

set pagesize 1000
set lines 100
col sid format 9999
col username format a12
col module format a30
column pga_memory_mb format 9,999.99 heading "PGA MB"
column max_pga_memory_mb format 9,999.99 heading "PGA MAX|MB"
col service name format a20
col sql_text format a70 heading "Currently executing SQL"
set echo on

WITH pga AS
(SELECT sid,
ROUND(SUM(CASE name WHEN 'session pga memory'
THEN VALUE / 1048576 END),2) pga_memory_mb,
ROUND(SUM(CASE name WHEN 'session pga memory max'
THEN VALUE / 1048576 END),2) max_pga_memory_mb
FROM v$sesstat
JOIN v$statname USING (statistic#)
WHERE name IN ('session pga memory','session pga memory max' )
GROUP BY sid)
SELECT sid, username,s.module,
pga_memory_mb,
max_pga_memory_mb, substr(sql_text,1,70) sql_text
FROM v$session s
JOIN (SELECT sid, pga_memory_mb, max_pga_memory_mb,
RANK() OVER (ORDER BY pga_memory_mb DESC) pga_ranking
FROM pga)
USING (sid)
LEFT OUTER JOIN v$sql sql
ON (s.sql_id=sql.sql_id and s.sql_child_number=sql.child_number)
WHERE pga_ranking <=5
ORDER BY pga_ranking
/

PGA incease When???

Whenever the value of the v$sysstat statistic estimated PGA memory for one-pass exceeds pga_aggregate_target, then you’ll want to increase pga_aggregate_target.


select name,value/1024/1024 from v$sysstat where name like '%pga%';

select value/1024/1024 from v$parameter where name like '%pga%';




Whenever the value of the v$sysstat statistic workarea executions—multipass is greater than 1 percent, the database may benefit from additional RAM memory.

select name,value from v$sysstat where name = 'workarea executions - multipass';




You can overallocate PGA memory and you may consider reducing the value of pga_aggregate_target whenever the value of the v$sysstat row workarea executions—optimal consistently measures 100 percent.

select name,value from v$sysstat where name = 'workarea executions - optimal';



---------------------------PGA top consumer-----------------

set pagesize 1000
set lines 100
col sid format 9999
col username format a12
col module format a30
column pga_memory_mb format 9,999.99 heading "PGA MB"
column max_pga_memory_mb format 9,999.99 heading "PGA MAX|MB"
col service name format a20
col sql_text format a70 heading "Currently executing SQL"
set echo on

WITH pga AS
(SELECT sid,
ROUND(SUM(CASE name WHEN 'session pga memory'
THEN VALUE / 1048576 END),2) pga_memory_mb,
ROUND(SUM(CASE name WHEN 'session pga memory max'
THEN VALUE / 1048576 END),2) max_pga_memory_mb
FROM v$sesstat
JOIN v$statname USING (statistic#)
WHERE name IN ('session pga memory','session pga memory max' )
GROUP BY sid)
SELECT sid, username,s.module,
pga_memory_mb,
max_pga_memory_mb, substr(sql_text,1,70) sql_text
FROM v$session s
JOIN (SELECT sid, pga_memory_mb, max_pga_memory_mb,
RANK() OVER (ORDER BY pga_memory_mb DESC) pga_ranking
FROM pga)
USING (sid)
LEFT OUTER JOIN v$sql sql
ON (s.sql_id=sql.sql_id and s.sql_child_number=sql.child_number)
WHERE pga_ranking <=5
ORDER BY pga_ranking
/

--------------------------------------------

Oracle Hidden Parameter

SELECT
n.ksppinm AS "name",
v.ksppstvl AS "value",
n.ksppdesc AS "description"
FROM
x$ksppi n,
x$ksppsv v
WHERE 1 = 1
AND n.indx = v.indx
ORDER BY
1;

Oracle 10g Scheduler Job Email Notification

1) connect sys as sysdba user and run two scripts for install and configure utl_mail package

SQL> conn sys@apx1213 as sysdba
Enter password: ******
Connected.
SQL> @d:\oracle\product\10.2.0\db_1\rdbms\admin\utlmail.sql

Package created.


Synonym created.

SQL> @d:\oracle\product\10.2.0\db_1\rdbms\admin\prvtmail.plb;

Package body created.

No errors.

2) Set SMTP_OUT_SERVER parameter for smtp_exchange_server. This parameter is not modifiable means we have to bounce our database to set this parameter

SQL> alter system set smtp_out_server = 'mail.apexsoftcell.com' scope=spfile;

SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup

3) Grant EXECUTE privs to user which use utl_mail package.

SQL> grant execute on utl_mail to ldbo;

Grant succeeded.

) Create procedure for Email Notification

create or replace procedure PRC_EMAIL (pSubject IN VARCHAR2, pMessage IN VARCHAR2) is
BEGIN
utl_mail.send(sender => 'info@apexsoftcell.com', recipients => 'kshitij@apexsoftcell.com', subject => pSubject, message => pMessage);
END;
/

4) Create Scheduler Job

BEGIN
DBMS_SCHEDULER.drop_JOB (job_name => 'compile');
END;
/


BEGIN
DBMS_SCHEDULER.create_job (
job_name => 'compile',
job_type => 'PLSQL_BLOCK',
job_action => 'DECLARE lnResult VARCHAR2(150);
BEGIN UTL_RECOMP.recomp_serial(''LDBO''); lnResult:=''SUCCESS'';
PRC_EMAIL(''Compile Notification'',lnResult);
EXCEPTION WHEN OTHERS THEN lnResult:=SUBSTR(SQLERRM,1,150);
PRC_EMAIL(''Compile Notification'',lnResult);
END;',
start_date => SYSTIMESTAMP,
repeat_interval => 'freq=hourly; byminute=0; bysecond=0;',
end_date => NULL,
enabled => TRUE,
comments => 'Compile job');
END;
/

5) Execute Job Manually
exec DBMS_SCHEDULER.run_job ('compile');

Thursday, March 15, 2012

Server Configuration Planning


1) Existing server configuration (Processor, No of CPU, RAM, Disk Capacity, … , …)

2) No. of running databases on server
3) Databases folder size of all years


select a.data_size+b.temp_size+c.redo_size+d.controlfile_size "DB_Folder_size_GB"
from ( select sum(bytes)/1024/1024/1024 data_size
from dba_data_files) a,
( select nvl(sum(bytes),0)/1024/1024/1024 temp_size
from dba_temp_files ) b,
( select sum(bytes)/1024/1024/1024 redo_size
from sys.v_$log ) c,
( select sum(BLOCK_SIZE*FILE_SIZE_BLKS)/1024/1024/1024 controlfile_size
from v$controlfile) d ;


4) Max concurrent connections in the database

Maximum concurrent connections (mcc) refers to the total number of sessions (connections) about which a device can maintain state simultaneously.

select highwater from dba_high_water_mark_statistics where name = 'SESSIONS';

select sum(inuse) from ( select name, round(sum(mb),1) mb, round(sum(inuse),1) inuse from (select case when name = 'buffer_cache' then 'db_cache_size'
when name = 'log_buffer'
then 'log_buffer'
else pool
end name,
bytes/1024/1024 mb,
case when name <> 'free memory'
then bytes/1024/1024
end inuse
from v$sgastat
)group by name );

select
(select highwater from dba_high_water_mark_statistics where name = ('SESSIONS'))*(2048576+a.value+b.value) pga_size
from
v$parameter a,
v$parameter b
where
a.name = 'sort_area_size'
and
b.name = 'hash_area_size'
;

5) Connections Per Second
Connections per second (c/s) refers to the rate at which a device can establish state parameters for new connections.

6) Transactions Per Second
Transactions per second (t/s) refers to the number of complete actions of a particular type that can be performed per second.

6) Weekly or monthly growth of databases.

database_monitoring_script

7) Oracle core license??

8) Network Load (Bandwidth,.........)




-------------------------------
Memory in a data warehouse is particularly important for processing memory-intensive operations such as large sorts. Access to the data cache is less important in a data warehouse because most of the queries access vast amounts of data. Data warehouses do not have memory requirements as critical as OLTP applications.

The number of CPUs provides you a good guideline for the amount of memory you need. Use the following simplified formula to derive the amount of memory you need from the CPUs you selected:

= 2 *
For example, a system with 6 CPUs needs 2 * 6 = 12 GB of memory. Most standard servers fulfill this requirement.

------------------------------

select * from dba_high_water_mark_statistics where name in ('SESSIONS','DB_SIZE');
select * from v$resource_limit;


--------maximum amount of memory allocated by the currently connected sessions
SELECT SUM (value/1024/1024) "max memory allocation" FROM v$sesstat ss, v$statname st WHERE st.name = 'session uga memory max' AND ss.statistic# = st.statistic#;


---------------------------Used SGA-----------------
select sum(inuse) from (
select name, round(sum(mb),1) mb, round(sum(inuse),1) inuse
from (select case when name = 'buffer_cache'
then 'db_cache_size'
when name = 'log_buffer'
then 'log_buffer'
else pool
end name,
bytes/1024/1024 mb,
case when name <> 'free memory'
then bytes/1024/1024
end inuse
from v$sgastat
)group by name );


-------------------pga requirement------------

select
(select highwater from dba_high_water_mark_statistics where name = ('SESSIONS'))*(2048576+a.value+b.value) pga_size
from
v$parameter a,
v$parameter b
where
a.name = 'sort_area_size'
and
b.name = 'hash_area_size'
;
-------------------------------------
http://docs.oracle.com/cd/B28359_01/server.111/b28314/tdpdw_system.htm

http://www.wdpi.com/product/used-hp/proliant-servers/ml570
http://h18004.www1.hp.com/products/quickspecs/12474_na/12474_na.html
http://en.wikipedia.org/wiki/Intel_QuickPath_Interconnect
http://www.intel.com/content/www/us/en/io/quickpath-technology/quickpath-technology-general.html
http://www.dfisica.ubi.pt/~hgil/utils/Hyper-Threading.4_Turbo.Boost.html
http://www.intel.com/content/www/us/en/architecture-and-technology/hyper-threading/hyper-threading-technology.html
http://h18000.www1.hp.com/products/quickspecs/13669_na/13669_na.html
http://www.cpubenchmark.net/multi_cpu.html

http://www.dbspecialists.com/files/presentations/mts_case_study.html

Configuration for LD DB:
2 Quad core processor 64 BIT (upgradable to 4 processor)
16 or 32 GB RAM
14 * 200 GB HDD (SAN)
Operating system : Win 2003 enterprise edition 64 bit

HP ProLiant ML570

Intel® Dual-Core 64-bit Xeon® processor 7000 sequence
Processor-4
3.00 GHz, 800MHz FSB
32 or 64 GB RAM

----------------------------------------------------------------------Eight Core Processor
Intel® Xeon® Processor E7-8837 product Family Xeon E7-8800
(24M Cache, 2.66 GHz, 6.40 GT/s Intel® QPI)
Thermal Design Power 130W (refers to the maximum amount of power the cooling system in a computer is required to dissipate.)


clock speed 2.66GHz
QPI (QuickPath Interconnect) is a point-to-point processor interconnect developed by Intel which replaces the Front Side Bus (FSB) in Xeon, Itanium, and certain desktop platforms.
Processor-2
Processor Core: Octa-core (8 Core) / Quad-core (4 core)

32 or 64 GB RAM

---------------------------
64-bit Intel® Xeon® Processor 24M Cache, 2.66 GHz, 6.40 GT/s Intel® QPI
with intel turbo boost technology / hyper threading technology

Most Used Processor: Intel® Xeon® Processor E7-8837 @ 2.66 GHz

Processor- 2 Quad-core (4 core)
32 or 64 GB RAM

-------------------------------------------------------------------Quad-Core Processors-----------------------

Intel® Xeon® E7520 (1.86GHz/4-core/18MB/95W) Processor
Memory 16 or 32 GB
Storage 8TB



--------------------------------------


The key to this dramatic claim is a feature called Turbo Boost technology. Basically, if the current application workload isn't keeping all four cores fully busy and pushing right up against the chip's TDP (Thermal Design Power) limit, Turbo Boost can increase the clock speed of each core individually to get more performance out of the chip.

---------------------------------------

Ten-Core Processors
Intel® Xeon® E7-4870 (2.40GHz/10-core/30MB/130W) Processor
Intel® Xeon® E7-4860 (2.26GHz/10-core/24MB/130W) Processor
Intel® Xeon® E7-4850 (2.00GHz/10-core/24MB/130W) Processor
Intel® Xeon® E7-8867L (2.13GHz/10-core/30MB/105W) Processor
Eight-Core Processors
Intel® Xeon® E7-8837 (2.67GHz/8-core/24MB/130W) Processor
Intel® Xeon® E7-4830 (2.13GHz/8-core/24MB/105W) Processor
Intel® Xeon® E7-4820 (2.0GHz/8-core/18MB/105W) Processor
Intel® Xeon® X7560 (2.26GHz/8-core/24MB/130W) Processor
Intel® Xeon® X7550 (2.0GHz/8-core/18MB/130W) Processor
Intel® Xeon® L7555 (1.86GHz/8-core/24MB/95W) Processor
Six-Core Processors
Intel® Xeon® E7-4807 (1.86GHz/6-core/18MB/95W) Processor
Intel® Xeon® E7540 (2.0GHz/6-core/18MB/105W) Processor
Intel® Xeon® E7530 (1.86GHz/6-core/12MB/105W) Processor
Intel® Xeon® X7542 (2.66GHz/6-core/18MB/130W) Processor
Quad-Core Processors
Intel® Xeon® E7520 (1.86GHz/4-core/18MB/95W) Processor

NOTE: New Intel Microarchitecture with Intel Virtualization Technology FlexMigration. Industry Standard Intel® 7500 Chipset with four high-speed interconnects up to 6.4GT/s.


Hardware Requirement

Minimum Hardware Requirements
On small instances, server load is primarily driven by peak visitors.

5 Concurrent Users

2GHz+ CPU
512MB RAM
5GB database space
25 Concurrent Users

Quad 2GHz+ CPU
2GB+ RAM
10GB database space
----------------------------------------------------------RAM---------

= 2 *

-------------------------------------Disk-----------

Use the following formula to determine the number of disk arrays you need:

= /

For example, a system with 1200 MB per second throughput requires at least 1200 / 180 = 7 disk arrays.

Ensure you have enough physical disks to sustain the throughput you require. Ask your disk vendor for the throughput numbers of the disks.

---------------------------
PGA_AGGREGATE_TARGET = 3 * SGA_TARGET.
----------------



-------------------Measure the Cost of Each Operation---------------

Cost per request. You can calculate the cost in terms of processor cycles required for processing a request by using the following formula:
Cost (Mcycles/request) = ((number of processors x processor speed) x processor use) / number of requests per second

For example, using the values identified for the performance counters in Step 2, where processor speed is 1.3 GHz or 1300 Mcycles/sec, processor usage is 90 percent, and Requests/Sec is 441, you can calculate the page cost as:

((2 x 1,300 Mcycles/sec) x 0.90) / (441 Requests/Sec) = 5.30 Mcycles/request

Cost per operation. You can calculate the cost for each operation by using the following formula:
Cost per operation = (number of Mcycles/request) x number of pages for an operation

The cost of the Login operation is:

5.30 x 3 = 15.9 Mcycles


---------------Calculate the Cost of an Average User Profile

Average cost of profile in Mcycles/sec = Total cost for a profile / session length in seconds
Thus, the average cost for the profile is:

147.52/600 = 0.245 Mcycles/sec


---------------------------------Calculate Site Capacity


To calculate these values, use the following formulas:

Simultaneous users with a given profile that your application can currently support. After you determine the cost of the average user profile, you can calculate how many simultaneous users with a given profile your application can support given a certain CPU configuration. The formula is as follows:
Maximum number of simultaneous users with a given profile = (number of CPUs) x (CPU speed in Mcycles/sec) x (maximum CPU utilization) / (cost of user profile in Mcycles/sec)

Therefore, the maximum number of simultaneous users with a given profile that the sample application can support is:

(2 x 1300 x 0.75)/0.245 = 7,959 users

Future resource estimates for your site. Calculate the scalability requirements for the finite resources that need to be scaled up as the number of users visiting the site increases. Prepare a chart that gives you the resource estimates as the number of users increases.
Based on the formulas used earlier, you can calculate the number of CPUs required for a given number of users as follows:

Number of CPUs = (Number of users) x (Total cost of user profile in Mcycles/sec) / (CPU speed in MHz) x (Maximum CPU utilization)

If you want to plan for 10,000 users for the sample application and have a threshold limit of 75 percent defined for the processor, the number of CPUs required is:

10000 x 0.245 / (1.3 x 1000) x 0.75 = 2.51 processors

Your resource estimates should also factor in the impact of possible code changes or functionality additions in future versions of the application. These versions may require more resources than estimated for the current version.



-------------------------------------------------------------------------------
Assessing Your Application Performance Objectives
At this stage in capacity planning, you gather information about the level of activity expected on your server, the anticipated number of users, the number of requests, acceptable response time, and preferred hardware configuration. Capacity planning for server hardware should focus on maximum performance requirements and set measurable objectives for capacity.
For your application, take the information that you derive from Examining Results from the Baseline Applications, to see how your application differs from one of the baseline applications. For example, if you are using the HTTPS protocol for a business application similar to MedRec, you should examine the metrics provided for the heavy MedRec application. Perform the same logical process for all of the factors listed in Capacity Planning Factors.
The numbers that you calculate from using one of our sample applications are of course just a rough approximation of what you may see with your application. There is no substitute for benchmarking with the actual production application using production hardware. In particular, your application may reveal subtle contention or other issues not captured by our test applications.


Calculating Hardware Requirements
To calculate hardware capacity requirements:
Evaluate the complexity of your application, comparing it to one or more of the applications described in Examining Results from the Baseline Applications. The example in Guidelines for Calculating Hardware Requirements identifies this value as the Complexity Factor. If your application is about as complex as one of the baselines, your Complexity Factor = 1.
Consider what throughput is required for your application. In the example, this is called the Required TPS (transactions per second).
Take the preferred hardware TPS value from the appropriate table. The example in Guidelines for Calculating Hardware Requirements identifies this value as the Reference TPS.



Guidelines for Calculating Hardware Requirements
The number of computers required is calculated as follows:
Number of boxes = (Required TPS) / (Reference TPS / Complexity Factor)
For example, if your assessment shows:
Your application is twice as complex as the Light MedRec application; the Complexity Factor = 2.
The requirement is for a 400 TPS; the Required TPS = 400.
The preferred hardware configuration is Windows 2000 using 4x700 MHz processors.
The Reference TPS is 205, from Table 2-3, configuration number lmW1.
The number of boxes required is approximately equal to:
400/(205/2) = 400/102.5 = next whole number, 3.90 rounded up = 4 boxes.
Always test the capacity of your system before relying on it for production deployments.
-----------------------


For data-warehouse project hard disk performance is everything. database cache, indexes, execution plans, memory, number of processors will not make any difference if your server hard disks are slow.

For example you have a table with 10 gigs of data with no indexes. Running select (*) from table will require a full scan of of the table you hardisk does 100mb per sec

10gig/100meg =10 000 /100 = 100sec

Is 100 sec acceptable for you?

---------------------

Disk Size depends on database size

disk speed depends on TPS (transactions per second)
--------------
RAM depends on sort operation,merge join,......no of concurrent sessions....
Using the Sort transform is a fully blocking operation. Whatever rows you're asking the Sort to work on will be blocked in the data flow until the sort completes. The Sort is significantly slower if it can't put all that data into RAM - so that's a critical limit you should design for. Take your max rows that you expect into a Sort multiplied by the row length.

The Merge Join is a partially blocking operation. You don't have to be as concerned about this as the Sort, but if your join is particularly "malformed", it could require a lot of RAM to buffer one of the inputs while the other waits for rows.

--------------------------------
number of processors and speed depends on your data processing

----------------------

Factors Affecting Capacity Planning
There are various factors to consider when conducting a capacity-planning exercise. Each of the following factors has a significant impact on system performance (and on system capacity as well).
- Operational load at backend
- Front end load
- Number of concurrent users/requests
- Base load and peak load
- Number of processes and Instances of processes
- Log size
- Archival requirements
- Persistence requirements
- Base recommendations from vendor
- Installation requirements
- Test results and extrapolation
- Interface Architecture and Performance Tuning
- Processing requirements and I/O operations
- Network bandwidth and latency
- Architecture resilience
- Network/Transmission losses
- Load factor loss
- Legacy interfacing loss/overheads
- Complexity of events and mapping
- Factor of safety

--------------

Hardware capacity determination
The hardware requirements can be evaluated based on the test results for a given set of conditions. There are several tools available to simulate clients (LoadRunner, WebLOAD, etc.). By simulating the transactions mix client load can be generated and load can be increased by adding more concurrent users. This is an iterative process, and the goal is to achieve as high CPU utilization as possible. If the CPU utilization doesn't increase (and hasn't yet peaked out) with the addition of more users, database or application bottlenecks are analyzed. There are several commercially available profilers (IntroScope, OptimizeIt, and JProbe) that can be used to identify these hot spots. In a finely tuned system, the CPU utilization (at steady state) in ideal case is usually less than 70%. While throughput won't increase with the addition of more load, response times, on the other hand, will increase as more clients are added. The capacity of the hardware is the point where the response time increases for additional load.






Database Growth Monitoring

Step : 1 Calculate total Size of tablespace

select sum(bytes)/1024/1024 "TOTAL SIZE (MB)" from dba_Data_files;


Step : 2 Calculate Free Space in Tablespace

select sum(bytes)/1024/1024 "FREE SPACE (MB)" from dba_free_space;

Step : 3 Calculate total size , free space and used space in tablespace

select t2.total "TOTAL DISK USAGE",t1.free "FREE SPACE",(t1.free/t2.total)*100 "FREE (%)",(t2.total-t1.free) "USED SPACE", (1-t1.free/t2.total)*100 "USED (%)"
from (select sum(bytes)/1024/1024 free from dba_free_space) t1 , (select sum(bytes)/1024/1024 total from dba_Data_files) t2 ;


Step : 4 Create table which is store all free/use space related information of tablespace

create table db_growth
as select *
from (
select sysdate,t2.total "TOTAL_DISK_USAGE",t1.free "FREE_SPACE",(t2.total-t1.free) "USED_SPACE",(t1.free/t2.total)*100 "FREE% "
from
(select sum(bytes)/1024/1024 free
from dba_free_space) t1 ,
(select sum(bytes)/1024/1024 total
from dba_Data_files) t2
);

Step : 5 Insert free space information in DB_GROWTH table (if you want to populate data Manually)

insert into db_growth
select *
from (
select sysdate,t2.total "TOTAL_SIZE",t1.free "FREE_SPACE",(t2.total-t1.free) "USED_SPACE",(t1.free/t2.total)*100 "FREE%"
from
(select sum(bytes)/1024/1024 free
from dba_free_space) t1 ,
(select sum(bytes)/1024/1024 total
from dba_Data_files) t2
);

COMMIT;


Step : 6 Create View on DB_GROWTH based table ( This Steps is Required if you want to populate data automatically)


create view v_db_growth
as select *
from
(
select sysdate,t2.total "TOTAL_SIZE",t1.free "FREE_SPACE",(t2.total-t1.free) "USED_SPACE",(t1.free/t2.total)*100 "FREE%"
from
(select sum(bytes)/1024/1024 free
from dba_free_space) t1 ,
(select sum(bytes)/1024/1024 total
from dba_Data_files) t2
)
;

Step : 7 Insert data into DB_GROWTH table from V_DD_GROWTH view


insert into db_growth select *
from v_db_growth;
COMMIT;


Step : 8 Check everything goes fine.

select * from db_growth;

Check Result

Step : 9 Execute following SQL for more time stamp information

alter session set nls_date_format ='dd-mon-yyyy hh24:mi:ss' ;
Session altered.

Step : 10 Create a DBMS jobs which execute after 24 hours

declare
jobno number;
begin
dbms_job.submit(
jobno, 'begin insert into db_growth select * from v_db_growth;commit;end;', sysdate, 'SYSDATE+ 1', TRUE);
commit;
end;
/


PL/SQL procedure successfully completed.

Step: 11 View your dbms jobs and it's other information

select * from user_jobs;


-----If you want to execute dbms jobs manually execute following command other wise jobs is executing automatically

exec dbms_job.run(ENTER_JOB_NUMBER)
exec dbms_job.run(23);



PL/SQL procedure successfully completed.

exec dbms_job.remove(21); ------to remove a job


Step: 12 Finally all data populated in db_growth table

select * from db_growth;

Followers