Which action would you like to make the query use the best plan for the selectivity?

You are administering a database supporting an OLTP application. The application runs a series
of extremely similar queries the MYSALES table where the value of CUST_ID changes.
Examine Exhibit1 to view the query and its execution plan.

Examine Exhibit 2 to view the structure and indexes for the MYSALES table. The MYSALES table
has 4 million records.

Data in the CUST_ID column is highly skewed.
Examine the parameters set for the instance:

Which action would you like to make the query use the best plan for the selectivity?

You are administering a database supporting an OLTP application. The application runs a series
of extremely similar queries the MYSALES table where the value of CUST_ID changes.
Examine Exhibit1 to view the query and its execution plan.

Examine Exhibit 2 to view the structure and indexes for the MYSALES table. The MYSALES table
has 4 million records.

Data in the CUST_ID column is highly skewed.
Examine the parameters set for the instance:

Which action would you like to make the query use the best plan for the selectivity?

A.
Decrease the value of the OPTIMIZER_DYNAMIC_SAMPLING parameter to 0.

B.
Us the /*+ INDEX(CUST_ID_IDX) */ hint in the query.

C.
Drop the existing B* -tree index and re-create it as a bitmapped index on the CUST_ID column.

D.
Collect histogram statistics for the CUST_ID column and use a bind variable instead of literal
values.

Explanation:
Using Histograms
In some cases, the distribution of values within a column of a table will affect the optimizer’s
decision to use an index vs. perform a full-table scan. This scenario occurs when the value with a

where clause has a disproportional amount of values, making a full-table scan cheaper than index
access.
A column histogram should only be created when we have data skew exists or is suspected.



Leave a Reply 5

Your email address will not be published. Required fields are marked *


Oleksii

Oleksii

D is not correct.

A snippet from doc above:
http://docs.oracle.com/cd/B19306_01/server.102/b14200/sql_elements006.htm

The DYNAMIC_SAMPLING hint instructs the optimizer how to control dynamic sampling to improve server performance by determining more accurate predicate selectivity and statistics for tables and indexes.

https://docs.oracle.com/cd/B19306_01/server.102/b14211/stats.htm#i42991

You control dynamic sampling with the OPTIMIZER_DYNAMIC_SAMPLING parameter, which can be set to a value from 0 to 10. The default is 2.

A value of 0 means dynamic sampling will not be done.

So, it means DYNAMIC_SAMPLE is switched off and it will not affect selectivity

Oleksii

Oleksii

I guess A is right

duff

duff

use 11g version but not 10!!!! In 11g there is bind-aware cursor feature.
my answer is D.

Aff

Aff

D correct

A is wrong – If dynamic sampling had been used, the plan output would have indicated this fact in a note. The optimizer did not use sampling because standard statistics exist and the dynamic sampling level is 2