Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> RE: View merging

RE: View merging

From: Koivu, Lisa <lkoivu_at_qode.com>
Date: Tue, 23 Jan 2001 13:32:50 -0500
Message-Id: <10750.127310@fatcity.com>


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_at_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_at_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_at_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_at_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_at_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_at_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"
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="MS Exchange Server version 5.5.2650.12">
<TITLE>RE: View merging</TITLE>
</HEAD>
<BODY>

<P><FONT SIZE=2>WOW.&nbsp; I learned something today. Wish I would have known that two years ago.</FONT>
</P>

<P><FONT SIZE=2>Thanks for sharing that with everyone, Djordje</FONT>
</P>
<BR>

<P><FONT SIZE=2>-----Original Message-----</FONT>
<BR><FONT SIZE=2>From: Djordje Jankovic [<A HREF="mailto:djankovic_at_corp.attcanada.ca">mailto:djankovic_at_corp.attcanada.ca</A>]</FONT>
<BR><FONT SIZE=2>Sent: Tuesday, January 23, 2001 12:21 PM</FONT>
<BR><FONT SIZE=2>To: Multiple recipients of list ORACLE-L</FONT>
<BR><FONT SIZE=2>Subject: RE: View merging</FONT>
</P>
<BR>

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

<P><FONT SIZE=2>-----Original Message-----</FONT>
<BR><FONT SIZE=2>Sent: Tuesday, January 23, 2001 11:42 AM</FONT>
<BR><FONT SIZE=2>To: Multiple recipients of list ORACLE-L</FONT>
</P>
<BR>
<BR>

<P><FONT SIZE=2>Have you tried writing another view with all the joins in it?&nbsp; Put the index</FONT>
<BR><FONT SIZE=2>hint in the view and it should work. </FONT>
</P>

<P><FONT SIZE=2>Views can screw up the optimizer.&nbsp; This is one case. </FONT>
</P>
<BR>

<P><FONT SIZE=2>-----Original Message----- </FONT>
<BR><FONT SIZE=2>&lt;<A HREF="mailto:djankovic_at_corp.attcanada.ca">mailto:djankovic_at_corp.attcanada.ca</A>&gt; ] </FONT>
<BR><FONT SIZE=2>Sent: Tuesday, January 23, 2001 10:56 AM </FONT>
<BR><FONT SIZE=2>To: Multiple recipients of list ORACLE-L </FONT>
</P>
<BR>

<P><FONT SIZE=2>Hi everybody, </FONT>
</P>

<P><FONT SIZE=2>I have a weird problem.&nbsp; A query does not want to merge a where clause with </FONT>
<BR><FONT SIZE=2>the view (as far as I know this should be default behavior).&nbsp; </FONT>
</P>

<P><FONT SIZE=2>So, I have something like </FONT>
</P>

<P><FONT SIZE=2>create view xxxx as </FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp; select table_a.field1, table_a.field_c, table_b.field2 </FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp; from table_a, table_b </FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp; where table_a.field_a = table_b.field_b; </FONT>
</P>

<P><FONT SIZE=2>When I run the query against the view: </FONT>
</P>

<P><FONT SIZE=2>select * </FONT>
<BR><FONT SIZE=2>&nbsp; from xxxx </FONT>
<BR><FONT SIZE=2>&nbsp;where field_c = 'aaa'; </FONT>
</P>

<P><FONT SIZE=2>where field_c is an indexed field from table_a, oracle does not use the </FONT>
<BR><FONT SIZE=2>index. </FONT>
</P>
<BR>

<P><FONT SIZE=2>However when I run (add the where clause to the view defining query): </FONT>
</P>

<P><FONT SIZE=2>select table_a.field1, table_b.field2 </FONT>
<BR><FONT SIZE=2>&nbsp; from table_a, table_b </FONT>
<BR><FONT SIZE=2>&nbsp;where table_a.field_a = table_b.field_b </FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp; and table_a.field_c = 'aaa'; </FONT>
</P>

<P><FONT SIZE=2>The index is used. </FONT>
</P>

<P><FONT SIZE=2>I tried both COST and RULE optimizer, tried giving hints (including the /*+ </FONT>
<BR><FONT SIZE=2>MERGE */ ) but nothing helped. </FONT>
</P>

<P><FONT SIZE=2>Any ideas, suggestions ? </FONT>
</P>

<P><FONT SIZE=2>Thanks. </FONT>
</P>

<P><FONT SIZE=2>Djordje </FONT>
</P>

<P><FONT SIZE=2>-- </FONT>
<BR><FONT SIZE=2>Please see the official ORACLE-L FAQ: http://www.orafaq.com</FONT>
<BR><FONT SIZE=2>&lt;http://www.orafaq.com&gt;&nbsp; </FONT>
<BR><FONT SIZE=2>-- </FONT>
<BR><FONT SIZE=2>Author: Djordje Jankovic </FONT>
<BR><FONT SIZE=2>&nbsp; INET: djankovic_at_corp.attcanada.ca </FONT>
</P>

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

<P><FONT SIZE=2>-- </FONT>
<BR><FONT SIZE=2>Please see the official ORACLE-L FAQ: http://www.orafaq.com</FONT>
<BR><FONT SIZE=2>-- </FONT>
<BR><FONT SIZE=2>Author: Djordje Jankovic</FONT>
<BR><FONT SIZE=2>&nbsp; INET: djankovic_at_corp.attcanada.ca</FONT>
</P>

<P><FONT SIZE=2>Fat City Network Services&nbsp;&nbsp;&nbsp; -- (858) 538-5051&nbsp; FAX: (858) 538-5051</FONT>
<BR><FONT SIZE=2>San Diego, California&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -- Public Internet access / Mailing Lists</FONT>
<BR><FONT SIZE=2>--------------------------------------------------------------------</FONT>
<BR><FONT SIZE=2>To REMOVE yourself from this mailing list, send an E-Mail message</FONT>
<BR><FONT SIZE=2>to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in</FONT>
<BR><FONT SIZE=2>the message BODY, include a line containing: UNSUB ORACLE-L</FONT>
Received on Tue Jan 23 2001 - 12:32:50 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US