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 11:44:59 -0500
Message-Id: <10750.127286@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_01C0855B.D2E9A1FE
Content-Type: text/plain;

        charset="iso-8859-1"

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-----
From: Djordje Jankovic [mailto:djankovic_at_corp.attcanada.ca] Sent: Tuesday, January 23, 2001 10:56 AM To: Multiple recipients of list ORACLE-L Subject: View merging

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_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_01C0855B.D2E9A1FE
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable


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

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

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

<P><FONT SIZE=3D2>-----Original Message-----</FONT>
<BR><FONT SIZE=3D2>From: Djordje Jankovic [<A =
HREF=3D"mailto:djankovic_at_corp.attcanada.ca">mailto:djankovic_at_corp.attcan= ada.ca</A>]</FONT>
<BR><FONT SIZE=3D2>Sent: Tuesday, January 23, 2001 10:56 AM</FONT>
<BR><FONT SIZE=3D2>To: Multiple recipients of list ORACLE-L</FONT>
<BR><FONT SIZE=3D2>Subject: View merging</FONT>
</P>
<BR>

<P><FONT SIZE=3D2>Hi everybody,</FONT>
</P>

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

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

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

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

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

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

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

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

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

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

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

<P><FONT SIZE=3D2>Thanks.</FONT>
</P>

<P><FONT SIZE=3D2>Djordje </FONT>
</P>

<P><FONT SIZE=3D2>-- </FONT>
<BR><FONT SIZE=3D2>Please see the official ORACLE-L FAQ: <A =
HREF=3D"http://www.orafaq.com" = TARGET=3D"_blank">http://www.orafaq.com</A></FONT>
<BR><FONT SIZE=3D2>-- </FONT>
<BR><FONT SIZE=3D2>Author: Djordje Jankovic</FONT>
<BR><FONT SIZE=3D2>&nbsp; INET: djankovic_at_corp.attcanada.ca</FONT>
</P>

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

Original text of this message

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