Improve performance of stored procedure

PL/SQL performance

PL/SQL it self is used to improve the performance. In application, most of logic implemented in java having communication with database to perform database operations. Database operation from java code for more number of iteration is not a good practice. It is always advisable, if the database call are performed under large number of iteration then move that logic into PL/SQL and perform those logic there. Significant performance can be achieved by doing this. While doing code transforming from java code into PL/SQL, developer may face number of difficulties.

Difficulty:
Q. How to pass array of two , array of three from java to PL/SQL?
Ans:- Oracle supports custom data types, where developer can create custom data type. The custom data type in the form of array of two ( i.e. pair of two strings / number ) , array of three ( triplate of  string / number ). Once those custom data type are defined in the oracle database then developer needs to form collection matching to those custom data type to send data from java code.

Q. use of "with" key word in Pl/SQL?
Ans:- "with" key word takes an extra memory to store the fetched data, resulting into slowness of PL/SQL execution. Instate of that developer can use the local variable and use that to increase the performance.

Q. Declaration of loop.
Ans :- it always advisable to declare the variables out side the loop to avoid the multiple declaration.

Passing a PL/SQL block containing multiple statements to the server can reduce network round trips, thereby improving performance.

Most of  the times developer needs to check data present using "IN" clause, instate of that "exist" clause is much faster.

The use of "decode" result into performance improvement and less code to write :).

Comments

Popular posts from this blog

Custom DataType in Oracle Database.

Reverse String, Unchanged position of special characters.

Java 8 Questions.