Oracle 11g: Multi-Column Correlation Without Extended Stats
Today I’ve been trying to reproduce in an 11g database one of the problems I faced with 10g—one on those problems Riyaj described in his Multi-Column Correlation and Extended Stats in Oracle 11g post. And the fun part is that I wasn’t able to reproduce it. Yet just setting optimizer_features_enable='10.2.0.4' made it show up again. It was as though Oracle can detect Multi-Column Correlation without Extended Statistics. How is this possible?
You don’t need any complicated schemas to check this out for yourself; just one table as below:
create table x (
a number,
b number,
c number);
begin
for i in 1..1000 loop
for j in 1..10 loop
insert into x values (j,j,j);
end loop;
end loop;
end;
/
commit;
exec dbms_stats.gather_table_stats(-
user,-
'X');
Execute a query with a WHERE clause containing two correlated columns:
explain plan for select c from x where a=1 and b=1; select * from table(dbms_xplan.display); -------------------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | -------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | 100 | 900 | 7 (0)| 00:00:01 | |* 1 | TABLE ACCESS FULL| X | 100 | 900 | 7 (0)| 00:00:01 | ————————————————————————–
The optimizer estimates the number of rows returned as 100, which is equivalent to considering that each one of the conditions in the WHERE clause returns 1000 rows, and that those columns are not correlated. (In that case that’s obviously wrong, because a equals b). So, no change with 10g? (more…)

