Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Oracle SQL :Bind variable Performance issues

Databases with an execution plan cache like SQL Server and the Oracle database can reuse an execution plan when executing the same statement multiple times. It saves effort in rebuilding the execution plan but works only if the SQL statement is exactly the same. 
If you put different values into the SQL statement, the database handles it like a different statement and recreates the execution plan.

1

SELECT first_name, last_name
FROM emp
WHERE empno = 20
When using bind parameters/variables to substitute the  val you do not write the actual values but instead insert placeholders into the SQL statement. That way the statements do not change when executing them with different values.

instead of the 1 you can use the following statement


SELECT first_name, last_name
FROM emp
WHERE empno = :empno
or 
SELECT first_name, last_name
FROM emp
WHERE empno = &empno
or 
SELECT first_name, last_name
  FROM emp
WHERE empno = p_empno


This post first appeared on EBiz Integration Technics, please read the originial post: here

Share the post

Oracle SQL :Bind variable Performance issues

×

Subscribe to Ebiz Integration Technics

Get updates delivered right to your inbox!

Thank you for your subscription

×