Message-Id: <10750.127310@fatcity.com> From: "Koivu, Lisa" Date: Tue, 23 Jan 2001 13:32:50 -0500 Subject: RE: View merging This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. ------_=_NextPart_001_01C0856A.E41FF0E0 Content-Type: text/plain; charset="iso-8859-1" WOW. I learned something today. Wish I would have known that two years ago. Thanks for sharing that with everyone, Djordje -----Original Message----- From: Djordje Jankovic [mailto:djankovic@corp.attcanada.ca] Sent: Tuesday, January 23, 2001 12:21 PM To: Multiple recipients of list ORACLE-L Subject: RE: View merging Thanks Lisa and others, I figured it out. The view has in its list of fields (don't ask me why) the "rownum" field. I know that this does not make any sense, but anyway. Btw, while digging through docs I found that if one has any type of set function (group function, distinct, ...) in the view definition it will not merge the query condition with the view definition. Djordje -----Original Message----- Sent: Tuesday, January 23, 2001 11:42 AM To: Multiple recipients of list ORACLE-L Have you tried writing another view with all the joins in it? Put the index hint in the view and it should work. Views can screw up the optimizer. This is one case. -----Original Message----- ] Sent: Tuesday, January 23, 2001 10:56 AM To: Multiple recipients of list ORACLE-L Hi everybody, I have a weird problem. A query does not want to merge a where clause with the view (as far as I know this should be default behavior). So, I have something like create view xxxx as select table_a.field1, table_a.field_c, table_b.field2 from table_a, table_b where table_a.field_a = table_b.field_b; When I run the query against the view: select * from xxxx where field_c = 'aaa'; where field_c is an indexed field from table_a, oracle does not use the index. However when I run (add the where clause to the view defining query): select table_a.field1, table_b.field2 from table_a, table_b where table_a.field_a = table_b.field_b and table_a.field_c = 'aaa'; The index is used. I tried both COST and RULE optimizer, tried giving hints (including the /*+ MERGE */ ) but nothing helped. Any ideas, suggestions ? Thanks. Djordje -- Please see the official ORACLE-L FAQ: http://www.orafaq.com -- Author: Djordje Jankovic INET: djankovic@corp.attcanada.ca Fat City Network Services -- (858) 538-5051 FAX: (858) 538-5051 San Diego, California -- Public Internet access / Mailing Lists -------------------------------------------------------------------- To REMOVE yourself from this mailing list, send an E-Mail message to: ListGuru@fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing). -- Please see the official ORACLE-L FAQ: http://www.orafaq.com -- Author: Djordje Jankovic INET: djankovic@corp.attcanada.ca Fat City Network Services -- (858) 538-5051 FAX: (858) 538-5051 San Diego, California -- Public Internet access / Mailing Lists -------------------------------------------------------------------- To REMOVE yourself from this mailing list, send an E-Mail message to: ListGuru@fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing). ------_=_NextPart_001_01C0856A.E41FF0E0 Content-Type: text/html; charset="iso-8859-1" RE: View merging

WOW.  I learned something today. Wish I would have known that two years ago.

Thanks for sharing that with everyone, Djordje


-----Original Message-----
From: Djordje Jankovic [mailto:djankovic@corp.attcanada.ca]
Sent: Tuesday, January 23, 2001 12:21 PM
To: Multiple recipients of list ORACLE-L
Subject: RE: View merging


Thanks Lisa and others,
 
I figured it out.  The view has in its list of fields (don't ask me why) the
"rownum" field.  I know that this does not make any sense, but anyway.  Btw,
while digging through docs I found that if one has any type of set function
(group function, distinct, ...) in the view definition it will not merge the
query condition with the view definition.
 
Djordje

-----Original Message-----
Sent: Tuesday, January 23, 2001 11:42 AM
To: Multiple recipients of list ORACLE-L



Have you tried writing another view with all the joins in it?  Put the index
hint in the view and it should work.

Views can screw up the optimizer.  This is one case.


-----Original Message-----
<mailto:djankovic@corp.attcanada.ca> ]
Sent: Tuesday, January 23, 2001 10:56 AM
To: Multiple recipients of list ORACLE-L


Hi everybody,

I have a weird problem.  A query does not want to merge a where clause with
the view (as far as I know this should be default behavior). 

So, I have something like

create view xxxx as
   select table_a.field1, table_a.field_c, table_b.field2
     from table_a, table_b
    where table_a.field_a = table_b.field_b;

When I run the query against the view:

select *
  from xxxx
 where field_c = 'aaa';

where field_c is an indexed field from table_a, oracle does not use the
index.


However when I run (add the where clause to the view defining query):

select table_a.field1, table_b.field2
  from table_a, table_b
 where table_a.field_a = table_b.field_b
   and table_a.field_c = 'aaa';

The index is used.

I tried both COST and RULE optimizer, tried giving hints (including the /*+
MERGE */ ) but nothing helped.

Any ideas, suggestions ?

Thanks.

Djordje

--
Please see the official ORACLE-L FAQ: http://www.orafaq.com
<http://www.orafaq.com
--
Author: Djordje Jankovic
  INET: djankovic@corp.attcanada.ca

Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
San Diego, California        -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru@fatcity.com (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).

--
Please see the official ORACLE-L FAQ: http://www.orafaq.com
--
Author: Djordje Jankovic
  INET: djankovic@corp.attcanada.ca

Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
San Diego, California        -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru@fatcity.com (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L