RE: View Mechanics

From: Lange, Kevin G <kevin.lange_at_ppoone.com>
Date: Fri, 2 Sep 2011 10:37:59 -0500
Message-ID: <F077F09A0E11504D9E720358BEE994D1088A4FA5_at_APSW0553EVS.ms.ds.uhc.com>



What we have seen is this:

  In the application, running a select from the view in the form of

      Select * from app_view where field_a = '123';

  Run a lot slower than running the EXACT code that makes up the view adding the line

      and field_a = '123'

In the underlying tables field_a is an indexed column. And the columns that join Table_1 to Table_2 to Table_3 are all indexed. Therefore I would expect the view to use the same path the sql behind the view when selecting from it.

What we saw when explaining the select from the view is that all three tables are doing Full Table Scans. When running the sql outside the view, the appropriate indexes are being used.

I just thought that, all things equal, the view would use the same methods to get the data that the SQl behind the view did. I had not seen this drastic a difference before.

-----Original Message-----

From: oracle-l-bounce_at_freelists.org
[mailto:oracle-l-bounce_at_freelists.org] On Behalf Of Powell, Mark Sent: Friday, September 02, 2011 7:48 AM To: Oracle-L List
Subject: RE: View Mechanics  

I am not sure I understand your wording but it is not uncommon to create a view whose SQL query would be a multiple table join of all rows and if you run select * from the view the performance would be pretty bad. However, when used in the application or by the end-user tool a where clause using an indexed column is provided in the query against the view which in turn when merged into the view code by the CBO results in a much more selective plan/performance.

-----Original Message-----

From: oracle-l-bounce_at_freelists.org
[mailto:oracle-l-bounce_at_freelists.org] On Behalf Of Lange, Kevin G Sent: Thursday, September 01, 2011 6:12 PM To: Oracle-L List
Subject: View Mechanics

I am just curious if its common for an Explain Plan of a view to have a totally different response than an explain plan of the SQL behind the view.  

Reason being, we have a very simple view made of of 3 tables that, when you explain it, it shows full table scans on all three tables. But, in the mean time, if you explain plan the SQL behind the view, you get index range scans on all three tables.  

Just makes no sense to me (which seems to be happneing more and more these days).  

System: Oracle 10.2.0.4 on a Solaris 10 machine. This e-mail, including attachments, may include confidential and/or proprietary information, and may be used only by the person or entity to which it is addressed. If the reader of this e-mail is not the intended recipient or his or her authorized agent, the reader is hereby notified that any dissemination, distribution or copying of this e-mail is prohibited. If you have received this e-mail in error, please notify the sender by replying to this message and delete this e-mail immediately.

--

http://www.freelists.org/webpage/oracle-l

--

http://www.freelists.org/webpage/oracle-l

This e-mail, including attachments, may include confidential and/or proprietary information, and may be used only by the person or entity to which it is addressed. If the reader of this e-mail is not the intended recipient or his or her authorized agent, the reader is hereby notified that any dissemination, distribution or copying of this e-mail is prohibited. If you have received this e-mail in error, please notify the sender by replying to this message and delete this e-mail immediately.

--

http://www.freelists.org/webpage/oracle-l Received on Fri Sep 02 2011 - 10:37:59 CDT

Original text of this message