Database Tuning (MOSC)

MOSC Banner

complex view w

edited Aug 1, 2019 2:57AM in Database Tuning (MOSC) 9 commentsAnswered ✓

Hello,

Please advise regarding Oracle optimizer behavior below:

In complex view with LEFT joins, if we select column which belongs to first table only, CBO still chooses the plan to scan all the tables.

As per my understanding, if only one column of view is used, then no other tables should be joined.

No indexes in this example, no FK's, just tables.

I understand that the proper answer is "not to use view in this case", but there is some application logic, when only view is available.

See example below:

create table A (id number, a varchar2(5));insert into A select rownum, 'A' from dual connect by rownum<100000;create table B(id number, b varchar2(5));insert into B select rownum, 'B' from dual connect by rownum<100000;create table C (id number, c  varchar2(5));insert into C select rownum, 'C' from dual connect by rownum<100000;commit;exec dbms_stats.GATHER_TABLE_STATS (OWNNAME=>user, TABNAME=>'A', METHOD_OPT=>'FOR ALL INDEXED COLUMNS SIZE AUTO', CASCADE=>true);exec dbms_stats.GATHER_TABLE_STATS (OWNNAME=>user, TABNAME=>'B', METHOD_OPT=>'FOR ALL INDEXED COLUMNS SIZE AUTO', CASCADE=>true);exec dbms_stats.GATHER_TABLE_STATS (OWNNAME=>user, TABNAME=>'C', METHOD_OPT=>'FOR ALL INDEXED COLUMNS SIZE AUTO', CASCADE=>true);

Howdy, Stranger!

Log In

To view full details, sign in to My Oracle Support Community.

Register

Don't have a My Oracle Support Community account? Click here to get started.

Category Leaderboard

Top contributors this month

New to My Oracle Support Community? Visit our Welcome Center

MOSC Help Center