How To Do Oracle PL SQL Performance Tuning
How To Do Oracle PL SQL Performance Tuning
Home SQLUs
QUERIES ORACLE
Privacy Policy ORACLE
Contact Us BI UNIX POSTGRESQL INTERVIEW Q/A
SQL WORLD
PARSE, BIND, OPTI MIZE, EXECUTE
Program :
DECLARE
V_No NUMBER;
V_Char CHAR(10);
BEGIN
V_No := V_No + 50; -- converted implicitly; slow CATEGORIES
V_No := V_No + 50.0; -- not converted; fast
V_Char := 25; -- converted implicitly; slow
V_Char := TO_CHAR(25); -- converted explicitly; still slow
BI Tutorials
V_Char := '25'; -- not converted; fast
END; Business Analyst
Data Mining
Oracle Errors
Oracle Upgrade
PLSQL Tutorials
PostgreSQL
Scrum Master
SQL Tutorials
A.Appropriate Index use:
Unix Interview Questions
User needs to create appropriate indexes on speci c column of the table. User should create the indexes on
columns in where condition of the statement. Unix Tutorials
1. User needs to create bit map indexes in case of distinct values in the table.
TAGS
Syntax:
Create bitmap index index_name on tablename(column_name); difference between simple view and complex
view
2. User needs to create simple index in case of non-distinct values. Equi join Inner Join
3. User needs to create composite index in case of joins (hash tables). View Views in SQL
Syntax:
User should gather the stats of tables after indexing the columns or changes in table structure. Kindly use the
subprogram of dbms_stats package to gather the stats.
C.Analyze the execution plan of SQL statement and try to improve performance :
1.Check the explain plan and try to reduce cost using indexes.
Try to avoid group by as well as distinct statements in SQL.User needs to rewrite the SQL statements whenever
necessary.
Try to replace the use of insert,update and delete loops to Forall statements.
The above statement will create the Employee2 table same as Employee1.
DECLARE
BEGIN
COMMIT;
END;
Use of bulk collect in case of Select into clause.The Bulk collect statement improves the performance of the
PLSQL block. When reading-in lots of related rows, bulk collect can run 10x faster than a conventional loop. This
tuning is possible because Oracle reduces context switches into a single operation.
DECLARE
TYPE test_bulk_collect IS TABLE OF s_srv_req%ROWTYPE;
V_test_bulkcollect test_bulk_collect;
CURSOR C_bulk_collect IS
SELECT *
FROM OF s_srv_req;
BEGIN
OPEN C_bulk_collect;
LOOP
FETCH C_bulk_collect
BULK COLLECT INTO l_tab LIMIT 10000; ——-10000 records collected with PLSQL engine
(No context switching)
DBMS_OUTPUT.put_line(V_test_bulkcollect.count || ‘ rows’);
EXIT WHEN C_bulk_collect %NOTFOUND;
END LOOP
CLOSE C_bulk_collect;
END;
Query :
5.Looping Practices :
It is very important to optimize the loops in PLSQL statement. Kindly follow the following practices while
working with loops.
Kindly initialize the variables outside the loop to improve the performance of the PLSQL block.
Try to use union,intersect,minus as well as Hierarchical queries of ‘connect by’ to improve the performance.
4. Bulk Collect :
Process set of rows with bulk collect statement in spite of using loops.
Use multiple string functions rather than use PLSQL block.Oracle has de ned set of pre de ned optimized string
functions like Replace,Instr,Substr,RPAD,LPAD etc.
If user wants to deal with regular expression make use of REGEX functions rather than writing whole code.
PLS_INTEGER :
When user wants to de ne normal integer; He/She tries to de ne the datatype as INTEGER or NUMBER.
PLS_INTEGER requires less storage than Integer or Number datatype. So try to use PLS_INTEGER in case of
INTEGER or Number datatype.
BINARY_INTEGER:
The Binary_Integer is same as PLS_INTEGER but PLS_INTEGER is faster in Oracle 9i and Oracle 8i.
BINARY_DOUBLE / BINARY_FLOAT :
Kindly use BINARY_DOUBLE or BINARY_FLOAT for oating point number declaration in PLSQL.
Example :
DECLARE
Name VARCHAR2(10);
BEGIN
END;
Lets take an example,when user needs the same report for speci c month again and again.The date range is same
so at that time user needs to set pro ler for that speci c query so that result will come fast.
Syntax of Hint :
16 X faster performance :
Always try to use append link while inserting the bunch of records.
Example :
These are some simple methods to tune the performance of PLSQL code. Hope this article will be helpful to
everyone who really want to do the PL SQL performance tuning.There are lot of new techniques and
methodologies used to tune the performance of plsql application.
How to use the DBMS_Pro ler in PL SQL Developer Roles and What is Full Form of PL SQL? PL
PL SQL? PL SQL Tuning -1 Responsibilities | Resume for PL SQL Full Form with simple
SQL Developer examples
Amit S says:
2. Muruganathan says:
Amit S says:
3. Vinothkumar says:
Amit S says:
4. Ramya says:
Amit S says:
Amit S says:
6. srinu says:
Amit S says:
http://www.complexsql.com/regexp_like-examples/
7. Rama says:
Amit S says:
Previous Next
What is SQL Create table with primary key OBIEE developer roles and responsibilities | OBIEE Resume
SQL WORLD | Designed by: Theme Freesia | WordPress | © Copyright All right reserved Home | About Us | Privacy Policy | Contact Us