OCP-1Z0-053-V12.02-165题

165.View the Exhibit exhibit1.

In the CUSTOMERS_OBE table, when the value of CUST_STATE_PROVINCE is "CA", the value of COUNTRY_ID is "US."

View the Exhibit exhibit2 to examine the commands and query plans. The optimizer can sense 8 rows

instead of 29 rows, which is the actual number of rows in the table. What can you do to make the

optimizer detect the actual selectivity?

A. Change the STALE_PERCENT value for the CUSTOMERS_OBE table.

B. Set the STATISTICS_LEVEL parameter to TYPICAL.

C. Create extended statistics for the CUST_STATE_PROVINCE and CUSTOMERS_OBE columns.

D. Set the OPTIMIZER_USE_PENDING_STATISTICS parameter to FALSE.

Answer: C

答案解析:

 参考:http://docs.oracle.com/cd/E11882_01/server.112/e41573/stats.htm#PFGRF94728

Managing Extended Statistics

DBMS_STATS enables you to collect extended statistics, which are statistics that can improve cardinality estimates when multiple predicates exist on different columns of a table, or when predicates use expressions. An extension is either a column group or an expression.

Oracle Database supports the following types of extended statistics:

  • Column group statistics

    This type of extended statistics can improve cardinality estimates when multiple columns from the same table occur together in a SQL statement. See"Managing Column Group Statistics".

  • Expression statistics

    This type of extended statistics improves optimizer estimates when predicates use expressions, for example, built-in or user-defined functions. 


Managing Column Group Statistics

When the WHERE clause of a query specifies multiple columns from a single table (multiple single column predicates), the relationship between the columns can strongly affect the combined selectivity for the column group.

For example, consider the customers table in the sh schema. The columns cust_state_province and country_id are related, with cust_state_provincedetermining the country_id for each customer. Suppose you query the customers table where the cust_state_province is California:

SELECT COUNT(*)
FROM   sh.customers
WHERE  cust_state_province = 'CA';

The preceding query returns the following value:

COUNT(*)
----------
    3341

Adding an extra predicate on the country_id column does not change the result when the country_id is 52790 (United States of America). Assume that you run the following query:

SELECT COUNT(*)
FROM   customers
WHERE  cust_state_province = 'CA'
AND    country_id=52790;

The preceding query returns the same value as the previous query:

COUNT(*)
----------
    3341

Assume that the country_id has a different value, such as 52775 (Brazil), as in the following query:

SELECT COUNT(*)
FROM   customers
WHERE  cust_state_province = 'CA'
AND    country_id=52775;

In this case the returned value is as follows:

COUNT(*)
----------
       0

With individual column statistics, the optimizer has no way of knowing that the cust_state_province and the country_id columns are related. By gathering statistics on these columns as a group (column group), the optimizer has a more accurate selectivity value for the group, instead of having to generate the value based on the individual column statistics.

You can create column groups manually by using the DBMS_STATS package. You can use this package to create a column group, get the name of a column group, or delete a column group from a table.


 
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值