Quote:
Originally Posted by ZeroQool
thanks! exist a performance different between dynamic and static?
|
There is some performance difference because you have to prepare the statement and then execute it. Also, I beleive that you will need to make all the other statements (open, fetch, etc) that refer to the cursor also be dynamic (unless there is some enhancement in a recent release of DB2 that I don't know about).
However, since most dynamic statements should already be in package cache from previous executions (if they are identical), a dynamic statement may not need to be re-compiled (to determine access plan) each time it is executed. Static (embedded) SQL statements are always compiled ahead of time when the SP is created (there is a package that is created along with the SP that contains the compiled SQL).
Overall, static SQL is usually faster, but the difference may not be significant. You should do testing to determine the difference if the transaction is critical.