oracle统计信息-11新特性多列统计信息
当where子句后指定了一个表的多个列条件时,优化器通常会将多个列的选择性(selectivity)相乘得到where语句的选择性,导致优化器做出错误判断! Oracle 11g引入了多列统计信息概念,如果上面情况列关联性很好,我们可以做多列统计信息收集,让优化器做出正确判断。 例如: SQL> select count(*) from sh.customers where CUST_STATE_PROVINCE = 'CA'; COUNT(*) ---------- 3341 SQL> select count(*) from sh.customers where CUST_STATE_PROVINCE = 'CA' and country_id=52790; COUNT(*) ---------- 3341 SQL> select count(*) from sh.customers where CUST_STATE_PROVINCE = 'CA' and country_id=52775; COUNT(*) ---------- 0 可以看出表customers的列CUST_STATE_PROVINCE、country_id是有关系的,只有多列统计信息才能让优化器知道他们的关系,从而有一个更精确的选择性(selectiveity)。 1 、创建 Column Group :