Tag Archives: performance

Testing Rate of Oracle inserts into a table

You can use any type of table or any data to see the rate of insert you are getting out of your Oracle RDBMS.   For this demonstration, we used a test table named INSERT_TEST and repeating insert of ever changing record sets.    You can change the scripts attached to satisfy your particular needs.

 

1.  Create table to hold insert records.

create table insert_test( var_a varchar2(100), var_b number(10,1));

2.  Insert a single record into your test table.

insert into insert_test VALUES(‘AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA’,999999999.9);

3.  Determine the size of row inserted.

SQL> select avg_row_len from dba_tab_statistics where table_name=’INSERT_TEST’; AVG_ROW_LEN

———–        

112

SQL>

4.  Edit the following script, replacing the record size with the actual size you received in step 3 above.

SET SERVEROUTPUT ON

DECLARE  

l_loops           NUMBER := 100000;

 l_start           NUMBER;

 total_time number;

v_ct  number:=0;

v_insert_ct number:=1.1;

v_var_a varchar2(100);

v_mb number;

v_rec_ct number;

record_size number:=112;  

BEGIN

   l_start := DBMS_UTILITY.get_time; 

  FOR i IN 1 .. l_loops LOOP

  v_insert_ct:=v_insert_ct+1; v_var_a:=’AAAAAAAAAAAAAAA’||v_insert_ct; insert into insert_test VALUES(v_var_a,v_insert_ct);

v_ct:=v_ct+1;

if v_ct>99

then

commit;

v_ct:=0;

 end if;

   END LOOP;   

 DBMS_OUTPUT.put_line(‘Execution Time   : ‘ ||(DBMS_UTILITY.get_time – l_start)||’  ms’); DBMS_OUTPUT.put_line(chr(10));

select round(100000/((DBMS_UTILITY.get_time – l_start)/100),2) into v_rec_ct from dual;

DBMS_OUTPUT.put_line(‘Number of Inserts per second: ‘||v_rec_ct||’ records’);

DBMS_OUTPUT.put_line(chr(10));

select round((100000/((DBMS_UTILITY.get_time – l_start)/100)*record_size)/1024/1024,2) into v_mb from dual;

DBMS_OUTPUT.put_line(‘MB of Inserts per second: ‘||v_mb|| ‘ MB’);

END; 

 /

5.  The result set below is returned, showing the insert rate achieved by your Oracle installation.   NOTE:  Multiple things will impact your insert rate, so for additional question leave a comment.

Execution Time   : 513  ms

Number of Inserts per second: 19493.18 records

MB of Inserts per second: 2.08 MB

PL/SQL procedure successfully completed.

SQL>

Larry Catt

Taking STATSPACK Snapshots and producing reports

Oracle’s STATSPACK performance diagnostic tool allows you to
analyze the performance of your Oracle RDBMS. This Analysis can be used to adjust parameters, determine high wait time events, and determine the SQL which causes the highest load on your system.

1. Logon to your Oracle database as sysdba.

mylunix:mydb:/mydb:>sqlplus ‘/ as sysdba’

SQL*Plus: Release 10.2.0.4.0 – Production on Tue Aug 2 07:38:57 2009

Copyright (c) 1982, 2007, Oracle. All Rights Reserved.

Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 – 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL>

2. The STATSPACK package is used to take snapshots, by calling the procedure snap. Take your first snapshot at the beginning of your peak usage and at evenly spaced intervals in between. IE: If your peak usage is between 8AM and 4PM, start taking your snapshots at 8AM and every 2 hours ( 10AM, 12PM, 2PM, and 4PM). This will allow you to take reports during the entire span of your peak usage and at intervals in between.

SQL> exec statspack.snap

PL/SQL procedure successfully completed.

SQL>

3. Once you are ready to take a report from you snapshots, you will have to find the snapshot ids which identify a specific snapshot range. This can be done by querying the table PERFSTAT.STATS$SNAPSHOT.

SQL> select snap_id, to_char(snap_time, ‘DD-MON-YY HH:MI:SS’) from
perfstat.stats$snapshot
where snap_time between to_date(’02-AUG-09 07:00:00′,’DD-MON-YY HH24:MI:SS’)
and to_date(’02-AUG-09 17:00:00′,’DD-MON-YY HH24:MI:SS’); 2 3

SNAP_ID TO_CHAR(SNAP_TIME,
———- ——————
1 02-AUG-09 08:22:29
11 02-AUG-09 10:00:07
21 02-AUG-09 12:00:03
31 02-AUG-09 14:00:12
41 02-AUG-09 15:00:48
42 02-AUG-09 14:00:47

6 rows selected.

SQL>

4. Once you have your high and low snap ids, call the Oracle script
$ORACLE_HOME/rdbms/admin/spreport.sql to generate an external trace file of your database performance. This script requires three input variables:
beginning snap_id, ending snap_id, and OS file name.

SQL> @?/rdbms/admin/spreport.sql

Listing all Completed Snapshots
Snap
Instance DB Name Snap Id Snap Started Level Comment
———— ———— ——— —————– —– ——————–
mydb mydb 1 02 Aug 2009 08:22 5
11 02 Aug 2009 10:00 5
21 02 Aug 2009 12:00 5
31 02 Aug 2009 14:00 5
41 02 Aug 2009 15:00 5
42 02 Aug 2009 16:00 5

Specify the Begin and End Snapshot Ids
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Enter value for begin_snap: 1
Begin Snapshot Id specified: 1

Enter value for end_snap: 42

5. Your report will be generated in the current working directory.

SQL> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 –
64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Dart:mylinux:/mydb>ls -lrt
-rw-r–r– 1 oracle dba 197698 Aug 2 16:38 sp_1_42.lst

This completes execution of STATSPACK SNAPSHOTS and generation of
STATSPACK reports.

Larry J. Catt, OCP 9i, 10g
oracle@allcompute.com
www.allcompute.com

Setup of Oracle STATSPACK Diagnostics tool

Oracle STATSPACK is a tool that allows you to analyze the performance of your Oracle RDBMS over a specific period of time. Normally the analysis of how your database is performing should be based over a period of the highest usage, but over a length of time that would avoid short term peaks to skew your results. STATSPACK has been in use since Oracle 8i with continual enhancements with every new version release. In this article, we will show how to install and prepare your database for the use of STATSPACK.

Also see:
Taking STATSPACK snap shots and producing reports.
Setup of STATSPACK scheduled jobs.

1. Logon to Oracle as sys dba

MyLinux:mydb:/mydb:>sqlplus ‘/ as sysdba’

SQL*Plus: Release 10.2.0.4.0 – Production on Mon Aug 3 09:03:30 2009

Copyright (c) 1982, 2007, Oracle. All Rights Reserved.

Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 – 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL>

2. The STATSPACK tool is owned by the user PERFSTAT and specific storage should be created to avoid interference with your database. In this step will create specific storage for PERFSTAT user.

SQL> create tablespace perfstat datafile ‘/mydb/ordata/perfstat01.dbf’ size 2096m;

Tablespace created.

SQL> alter tablespace perfstat add datafile ‘/mydb/ordata/perfstat02.dbf’ size 2096m;

Tablespace altered.

3. The user PERFSTAT and all components of the STATSPACK tool are created with the ORACLE provided script SPCREATE.SQL. Execute the script $ORACLE_HOME/rdbms/admin/spcreate.sql to create the perfstat user and data structures.

SQL> @?/rdbms/admin/spcreate.sql

4. The SPCREATE.SQL script accept three parameters before execution: Password; Default Tablespace; and Temp Tablespace. Enter the following when prompted:
PERFSTAT Password
Default Tablespace
Temp Tablespace

5. After execution has occurred, check the following list files to determine that no errors occurred.

spcusr.lis – Creates the perfstat user account.
spctab.lis – Creates all data structure under the perfstat user account.
spcpkg.lis – Creates the perfstat packages.

6. This completes the build of Oracle’s STATSPACK diagnostic tool in your database.

Larry J Catt, OCP 9i, 10g
oracle@allcompute.com
www.allcompute.com