Which three features work together, to allow a SQL statement to have different cursors for the
same statement based on different selectivity ranges?
A.
Bind Variable Peeking
B.
SQL Plan Baselines
C.
Adaptive Cursor Sharing
D.
Bind variable used in a SQL statement
E.
Literals in a SQL statement
Explanation:
* In bind variable peeking (also known as bind peeking), the optimizer looks at the
value in a bind variable when the database performs a hard parse of a statement.
When a query uses literals, the optimizer can use the literal values to find the best plan. However,
when a query uses bind variables, the optimizer must select the best plan without the presence of
literals in the SQL text. This task can be extremely difficult. By peeking at bind values the optimizer
can determine the selectivity of a WHERE clause condition as if literals had been used, thereby
improving the plan.
C:Oracle 11g/12g uses Adaptive Cursor Sharing to solve this problem by allowing the server to
compare the effectiveness of execution plans between executions with different bind variable
values. If it notices suboptimal plans, it allows certain bind variable values, or ranges of values, to
use alternate execution plans for the same statement. This functionality requires no additional
configuration.
ACE
ok
A C and E appears to be correct.
http://docs.oracle.com/database/121/TGSQL/tgsql_cursor.htm
ACE
If I use Literals, I don’t have the same(!) statement with different selectivity ranges. I have different statements. So this does not make sense for literals I think.
=> ACD
Sorry, I think they mean, literals + cursor_sharing=force. This is ok, of course. But Use of Bind Variables will also be ok or what do you mean?
ACE if CURSOR_SHARING=FORCE
ACD is CURSOR_SHARING=
Having said that, you can;t have Bind Peeking unless CURSOR_SHARING is FORCE, so we have to assume CURSOR_SHARING=FORCE so that would have ACE correct.
and from the Docs:
When CURSOR_SHARING is set to FORCE, the database uses one parent cursor and one child cursor for each distinct SQL statement. The database uses the same plan for each execution of the same statement.
If the initialization parameter CURSOR_SHARING=EXACT (default), and if a statement in the pool is not identical, then the database does not share the SQL area. Each statement has its own parent cursor and its own execution plan based on the literal in the statement.
The questions asks “…SQL statement to have DIFFERENT CURSORS for the SAME STATEMENT based on DIFFERENT SELECTIVITY RANGES” which indicates CURSOR_SHARING=EXACT although both FORCE and EXACT generate different cursors for the same statement.
http://docs.oracle.com/database/121/TGSQL/tgsql_cursor.htm#TGSQL848
Adaptive cursor sharing is independent of the CURSOR_SHARING initialization parameter. Adaptive cursor sharing is equally applicable to statements that contain user-defined and system-generated bind variables. Adaptive cursor sharing does not apply to statements that contain only literals.
ACE
Based on the Relo’s points and the documentation,
In order to have different cursors for the same statement, it should be AC and E.
If we use bindvariables, the same cursor will be used, if we use literals instead, the cursor will be changed for each literal.
ACE
A bind variable is a placeholder in a SQL statement that must be replaced with a valid value or value address for the statement to execute successfully. By using bind variables, you can write a SQL statement that accepts inputs or parameters at run time. The following query uses v_empid as a bind variable:
SELECT * FROM employees WHERE employee_id = :v_empid;
When a query uses literals, the optimizer can use the literal values to find the best plan. However, when a query uses bind variables, the optimizer must select the best plan without the presence of literals in the SQL text. This task can be extremely difficult. By peeking at bind values, the optimizer can determine the selectivity of a WHERE clause condition as if literals had been used, thereby improving the plan.
Use bind variables rather than literals in SQL statements whenever possible.
For example, the following statements cannot use the same shared area because they do not match character for character:
SELECT employee_id FROM employees WHERE department_id = 10;
SELECT employee_id FROM employees WHERE department_id = 20;
By replacing the literals with a bind variable, only one SQL statement would result, which could be executed twice:
SELECT employee_id FROM employees WHERE department_id = :dept_id;
In SQL parsing, an identical statement is a statement whose text is identical to another, character for character, including spaces, case, and comments. A similar statement is identical except for the values of some literals.
When SQL statements use literals rather than bind variables, a nondefault setting for the CURSOR_SHARING initialization parameter enables the database to replace literals with system-generated bind variables. Using this technique, the database can sometimes reduce the number of parent cursors in the shared SQL area.
So the correct answers are:
A,C,D
I think – ACD
Since Default CURSOR_SHARING is EXACT, i would assume that when you use litererals (D), it doesn’t generate or look for different cursor. So I would go with “D” since whatever the CURSOR_SHARING is set – this looks for different cursor and plans.
ACD .
E is wrong, because it doesn’t WORK TOGETHER with other options.
So, the answer is:
A, C and D.
ACD
E is wrong because Adaptive cursor sharing does not apply to statements that contain only literals.
for me it appears to be BCD.
E is definetly wrong.
And when Oracle uses bind peeking, it uses the same child cursor no matter the change in the variables in subsequent executions.
A SQL Plan baseline stores additional information that helps Oracle to identify the right plan.
…Which three features work together…
Adaptive cursor sharing (C) can generate different plans based on value of bind variable. To use this feature, SQL statement has to have bind variables(D) and Oracle has to read value of bind variable(A).
so ACD features works _together_
agree with test5678 🙂
may be B
https://blogs.oracle.com/optimizer/entry/how_do_adaptive_cursor_sharing
ACD is my answer.
B promotes plan stability rather than different plans
E is incorrect as different literals mean different SQLs
On top, bind variable peeking implies use of bind variables
A wrong: In bind variable peeking (also known as bind peeking-sbirciare), the optimizer looks at the value in a bind variable only when the database performs a hard parse of a statement (does not look at the bind variable values in every parse) Optimizer peeks bind only when the optimizer is first invoked (which is during the hard parse).
B right: Since both plans are accepted in SQL Plan Baselines, both are eligible for execution which could be helpful in situations where a adaptive cursor sharing kicks in and the full scan would actually be the better plan.
C right: The adaptive cursor sharing feature enables a single statement that contains bind variables to use multiple execution plans. Cursor sharing is “adaptive” because the cursor adapts its behavior so that the database does not always use the same plan for each execution or bind variable value.
D wrong: with bind variable the execution plan is olways the same
E right: with literals values in “where” condition, the query every time take an different execution plan
B, C, E..
Right??
Hi, i have passed my Oracle 1Z0-060 exam last week, score of my 1Z0-060 exam: Section 1 = 90%; Section 2 = 92% (the passing score: Section 1 = 64%; Section 2 = 65%, both sections must be passed to pass 1Z0-060 exam). All 85 questions (Section 1 = 51q; Section 2 = 34q) were multiple choice questions, most of them were easy to answer, but few questions on Core Administration and Performance Management were a little difficult.
And, I learned valid 1Z0-060 dumps here: http://www.passleader.com/1z0-060.html (recommend to get FULL VERSION 1Z0-060 VCE dumps and PDF dumps for learning).
Good Luck!
P.S. Free 1Z0-060 PDF dumps from Google Drive: https://drive.google.com/open?id=0B-ob6L_QjGLpNjQta2dQSmFJLWs
ACD