11.07.2015 Views

Oracle Database 11 g - Online Public Access Catalog

Oracle Database 11 g - Online Public Access Catalog

Oracle Database 11 g - Online Public Access Catalog

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

172 CHAPTER 4 ■ PERFORMANCE MANAGEMENTFaster DML TriggersThis is one of the new features of <strong>Oracle</strong> <strong>Database</strong> <strong>11</strong>g that doesn’t require you to do anythingto reap the benefits! All DML triggers run much faster in <strong>Oracle</strong> <strong>Database</strong> <strong>11</strong>g. According to oneof <strong>Oracle</strong>’s internal tests, there was a 25 percent improvement in the performance speed of arow-level update trigger fired during DML. Please see Chapter <strong>11</strong> for several new triggerrelatedfeatures.Adaptive Cursor SharingUsing bind variables reduces the amount of shared memory the database needs to allocateto parse SQL statements, because bind variables reuse a single cursor for multiple executionsof the same (or similar) SQL statement. Bind variables, because they reduce parse time andmemory usage, enhance the performance and scalability of the database, especially when youhave a large number of concurrent users. The initialization parameter cursor_sharing determineswhich SQL statements can share the same cursor. Setting the cursor_sharing parameterto exact stipulates that only identical statements can share a cursor. Setting the parameter toforce means statements that differ in some literals can share a cursor. Setting the parameter tothe value similar leads to the same behavior as setting it to force unless the different values ofthe literals affect the degree of optimization of the execution plan.However, cursor sharing inherently conflicts with SQL optimization, because specifyingliteral values instead of bind values provides richer information to the optimizer, leading to theevolution of better plans. For this reason, forced cursor sharing especially could lead to suboptimalexecution plans. In some cases, some users of a SQL statement may get highly optimalexecutions, while others may get quite inferior executions because of the specific values of theactual bindings.Columns with heavily skewed data distribution need different execution plans based onthe actual values of the bind variables in a SQL query, and when you bind variables, you mayend up with suboptimal execution plans as a result. <strong>Oracle</strong> uses the concept of bind peeking,under which the optimizer examines the bind values the first time you execute a statement inorder to evolve an optimal execution plan for subsequent executions of that statement. Theoptimizer will look at the bind variable values during the first hard parse and base its planstrategy on those values. Bind variable peeking helps you only when the optimizer first generatesthe execution plan for a new SQL statement. However, if the data is heavily skewed, bindpeeking has little value, because different data for the bind variables requires different executionplans, making the use of literals a better strategy. For example, if the values the optimizersees during its “peeking” warrant using an index, it’ll continue to use the index even for othervalues of the bind variable when a full scan may be a better strategy!<strong>Oracle</strong> <strong>Database</strong> <strong>11</strong>g takes a major step to resolve the inherent conflict between cursorsharing and query optimization by introducing the concept of adaptive cursor sharing. Underadaptive cursor sharing, the SQL statements automatically share a cursor. <strong>Oracle</strong> generatesmultiple execution plans for a statement that uses bind variables, when it detects that the costof doing so for a particular SQL statement outweighs the benefit of a lower parse time andmemory usage flowing from using the same cursor. <strong>Oracle</strong> still attempts to keep the number ofgenerated child cursors to a minimum to take advantage of cursor sharing. In a nutshell, what<strong>Oracle</strong> is attempting to do is avoid the “blind sharing” of cursors while minimizing the numberof child cursors.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!