Optimizing SQL for views on views

i'm trying to optimize the performance of a view, which joins 2
other views:
select *
from v1, v2
where v2.xxx = v1.xxx
when i select data from the view, i set a where clause that
results in only one matching row in the view v1 that can be
accessed by rowid (unique index). There is also a (none-unique)
index on the column xxx of that v2 view which should by used by
the optimizer (rule-based, 7.3.4.3.0).
But it isn't. Instead the database performs a full table scan of
the driving table of the v2 view, finds some rows and merges the
data with those from the v1 view. But as the v2 view is very
large it takes very long....
When i type
select * from v2 where xxx='abc'
the query executes qickly because the index on xxx is used.
What can prevent the optimizer from using the index on xxx in my
view?
I even tried to force use of the index by the INDEX hint but it
didn't work.
any help appreciated
thanks
null

Thanks kgronau,
My Oracle gateway for SQL server is in a Linux box and obviously the SQL server in a windows box.
In that case how I would execute dg4msql_cvw.sql which is under $ORACLE_HOME/dg4msql/admin path of Linux server?
Regards
Satish

Similar Messages

  • SQL for views with constraints

    We use a product that requires us to have pk's on all of our views. So when I generate the SQL using DBMS_METADATA or using SQL Developer we have to keep the original scripts so that we can manually insert the constraint definition into the generated script.
    I noted that while browsing the SQL tab for each view I can see the constraint in the view definition. So where is this tab generating it's SQL from? It's not in the text of the view, and dbms_metadata does not seem to do it.
    It would be useful for me to be able to generate them with the constraint in the text already as this process that we do now is cumbersome.
    Can anyone tell me where/how I can do that?
    Cheers,
    Henri

    OK, here is little test:
    alter view emp_sal
    add constraint emp_sal_uk unique (ename) DISABLE NOVALIDATE ;
    After that command the view definition is
    CREATE OR REPLACE FORCE VIEW "SCOTT"."EMP_SAL" ("EMPNO", "ENAME", "SAL",
         UNIQUE ("EMPNO") RELY DISABLE,
         CONSTRAINT "ID_PK" PRIMARY KEY ("EMPNO") RELY DISABLE,
         CONSTRAINT "EMP_SAL_UK" UNIQUE ("ENAME") DISABLE) AS
    SELECT empno, ename, sal FROM emp;
    so that the constraint becomes effectively inline. It is displayed with
    select dbms_metadata.GET_DDL('VIEW', 'EMP_SAL') from dual;

  • SQL for View Definition using outer join

    Hello everyone,
    I am creating a view using the statement below
    SELECT *
    FROM table_a A
    ,table_b B
    ,table_c C
    WHERE A.sg_code = B.sg_code and
    B.st_code = 'E' and
    A.sg_code = C.sg_code(+) and
    C.st_code = 'T'
    The structure of the view is as follows
    View
    sg_code| Name | start_date | end_date |
    1 | Test |13-03-2008 | NULL |
    Table_a
    sg_code,Name
    Table_b
    sg_code,st_code,actual_date
    the view can have a null for the column 'end_date'
    This means there will not be a record inserted in the Table_b for end_date=null, there will only be a record for actual_date=start_date
    In this scenario when I query the view I am not seeing the newly created record just because there is a condition "C.st_code = 'T'" with the outer join on the sg_code.
    When I look into the individual tables I see the records.
    Table A
    Pg_code,Name
    1 Test
    Table B
    Id pg_code As_of_date
    1 1 13-03-2008
    How should I modify my view definition so that I can query the view even if there is a null for 'end_date'
    Thanks
    fm

    the last line should be:
    C.st_code(+) = 'T'
    by failing to include the (+) on that line, you made it NOT an outer join. an outer joined table must be outer joined on every where criteria, including to constants.

  • Optimized sql not properly generated when using SAP tables

    Hi Experts
    We are using BODS 4.1 sp2.
    We have a simple dataflow where we pull data from SAP r3 using direct download and push it in our database.
    Basically its like this:
    SAP Table-->Query Transform-->Oracle Database
    Inside query transform,we have applied some conditions in where clause,which are combinations of 'or' and 'and' operator.
    However when we are generating optimized SQL for the same,we observe that the conditions in where clause are not being included in the optimized query.
    But if we replace all conditions by only 'or'  or by only 'and' condition,the optimized sql query with condition  is generated.
    Somehow the optimized sql with conditions is not generated if where clause has mixer of 'and' and 'or' conditions.
    The issue is only observerd for SAP Tables
    However the same dataflow in bods 4.0,generates an optimized sql containing the mixed conditions of 'and' and 'or' in where clause.
    Please help me on this.

    Dear Shiva
    We e
    Let me explain this in detail to you:
    We have a simple dataflow where we push data from the sap table directly into our oracle database.
    The dataflow has a query transform where we have some conditions to filter the data.
    The method used to pull data from R3 is direct download.
    System Used:
    BODS 4.2 SP1
    SAP R3 620 release(4.7)
    The where clause has mixed 'and' and 'or' operators.The problem is that this where clause is not getting pushed in the Optimized sql.
    Eg: Table1.feild1=some value and Table1.feild2=some value or Table1.feild3=some value.
    If this is the condition in  where clause,the where clause does not appear in optimized sql.
    Also the condition in where clause is from same table.
    However if all the condition in where clause are either all 'and'  or either all 'or',the condition gets pushed and appears in optimized sql.
    But if their is mixed 'and' and 'or' it fails.
    The same was not the case when we used BODS 4.0 with R3 620(4.7).
    We investigated further and used R3 730 with BODS 4.2.With R3 720,we the where condition was getting pushed into optimized sql for mixed 'and' 'or' predicated.
    SAP support too confirmed the same.They were able to reproduce the issue.
    We will use ABAP dataflow and see if if resolves the issue.
    Regards
    Ankit

  • How to build sql query for view object at run time

    Hi,
    I have a LOV on my form that is created from a view object.
    View object is read-only and is created from a SQL query.
    SQL query consists of few input parameters and table joins.
    My scenario is such that if input parameters are passed, i have to join extra tables, otherwise, only one table can fetch the results I need.
    Can anyone please suggest, how I can solve this? I want to build the query for view object at run time based on the values passed to input parameters.
    Thanks
    Srikanth Addanki

    As I understand you want to change the query at run time.
    If this is what you want, you can use setQuery Method then use executeQuery.
    http://download.oracle.com/docs/cd/B14099_19/web.1012/b14022/oracle/jbo/server/ViewObjectImpl.html#setQuery_java_lang_String_

  • How to maintain Entries for VIEWS in ORacle Sql developer

    hi gurus,
    Could you please help in maintaining an entries for VIEW is Oracle SQL develope...I have created a VIEW by name SD_WH08....now i need to maintain some entries in this for my testing purpose...how do i do this?
    Your help is very much appreciated.
    Regards

    What do you mean by "maintaining an entries for VIEW" ?
    K.

  • IF statement syntax in SQL script view

    I need to include a "IF" condition in the "SELECT" section of my SQL script view.
    I tried the following syntax's but I get the error 'Incorrect SQL syntax near 'IF'
    1.  IF(Revenue <> '0' AND Quantity <> '0', Revenue/Quantity, '0') AS Gross Price
    2.  IF(Revenue != '0' AND Quantity != '0', Revenue/Quantity, '0') AS Gross Price
    3.  IF(Revenue <> '0' AND Quantity <> '0' THEN Revenue/Quantity ELSE  '0' END) AS Gross Price
    4.  IF(Revenue != '0' AND Quantity != '0' THEN Revenue/Quantity ELSE  '0' END) AS Gross Price
    My final SQL would read like follows:
    SELECT field1, field2, IF(......) AS field3
    FROM table1
    Can anybody please help with the correct IF statement syntax to be used in the SQL script based view?

    Hi Lakshmi,
    below is the syntax for IF statement.
    IF <bool_expr1> THEN
    <then_stmts1>
    ELSEIF <bool_expr2>
    THEN <then_stmts2>
    [ELSE <else_stmts3>]
    END IF
    eg :
    BEGIN
    DECLARE found INT := 1;
    SELECT count(*) INTO found FROM books WHERE isbn = :v_isbn;
    IF :found = 0 THEN
    INSERT INTO books VALUES (:v_isbn, 'In-Memory Data Management', 1, 1, '2011', 42.75, 'EUR');
    ELSE
    UPDATE books SET price = 42.75 WHERE isbn =:v_isbn;
    END IF;
    END;
    Sreehari

  • How to install an external editor in version 2.1.1.64 for viewing XMLType

    I have a question about viewing XMLType in version 2.1.1.64
    If you want to view the content of an XMLType column in a data-tab, you can double click on the particular XMLType field and the edit button appears at the end. Push this edit button and an "Edit Dialog" popup appears with the data presented as one line.
    Push the External Editor button and you get a dialog that informs you about the not supported mime type of the selected object. You can find the complete list of supported mime types in Tools->Preferences->External Editor panel. I like to use an external XML editor for viewing an xmltype column, can anyone put me on the right track? Change the Editor Location for the .xml file extension didn`t work.
    Kind regards,
    Erwin Snippert

    This is the case:
    SQL Developer version 2.1.1.64
    Oracle client 11gR2
    Oracle Database 9.2.0.6.
    Under the table tree, on the left side of the screen, a table is selected with 3 columns. One of them is a XMLType column.
    Click on the data tab on the right side of the screen and a part of the xml-data is visible of that XMLType column.
    Perhaps my expectations are too high, i want to see the all XML data in a structured and readable way.
    I have tried to accomplish this by double clicking on the particular data in the XMLType column. This results in an pencil icon on the right side of the data.
    Click on this icon and a popup window appears with the 'Edit Value' titel. This windows shows the xml data as one string, not very readable.
    I have the oppurtunity to click on an 'External Editor' button. It seems to me that i can use this button to see/edit the data with an external editor.
    If you click on this button, a dialog appears with the following message : 'The Mime Type of selected object is currently not supported. Please see the complete list of supported Mime Type and extension in Tools>Preferences>External Editor panel.'
    I have 2 questions, perhaps you can put me in the right direction :
    - Why can't SQL developer standard display XML in a structured/readable way?
    - How must SQL Developer be configured to use an external editor for displaying XML data from XMLType columns?
    Kind Regards, Erwin

  • Tool for Viewing 3D data in Oracle 10g

    Hi,
    I had uploaded the 3D DGN format Data from FME Oracle Suite to Oracle 10g database.
    the following tables were created
    TESTASH_SDODIM TABLE
    TESTASH_SDOLAYER TABLE
    TESTASH_SDOGEOM TABLE
    TESTASH_SDOINDEX TABLE
    TESTASH TABLE
    When we are trying to browse the data using AutoCAD of any other viewer, we are unable to find this table in that particular user. Whereas if we run a sql command and run a sql query we are able to get the record count.
    Can you suggest something to view this data.
    Thanks and Regards
    Ashish Dhawan

    Ok.. I'd bet then that there are no entries in USER_SDO_GEOM_METADATA AKA MDSYS.SDO_GEOM_METADATA_TABLE. FME view needs to find an entry in there to show you it in the dialog so you can pick the table. The same holds true for views of tables, there needs to be an entry, although I find it somewhat ironic that it then goes on to not know what projection the data is in.
    Also, the viewer will pick the first SDO_GEOMETRY column it finds. So if you have more than one, you will then need to make a view for just that column.
    Anyway, add an entry into the table, and you should be good to go.
    Bryan

  • SQL Report Viewer Web Part Not displaying Report

    I have just completed updating an old report using report builder 3.0. I have added it to SharePoint Designer but have not replaced the old report file. 
    Any help is greatly appreciated!!
    All I did was export the old report from sharepoint designer to my desktop. Then opened it with Report Builder 3.0- made changes to the report and saved it with a different name (for safety in case i break things) and then upload it back to the same place where
    the old report was located using SP Designer. I then went back to the site in sharepoint that is displaying the old report, and changed the URL path in the SQL report viewer to the new report. 
    Now the SQL Report Viewer web part isn't showing anything (blank)

    Dear Form Moderator,
    This question is already asked in sharepoint forum so please don't move this sharepoint forum. Here is link of thread:
    https://social.technet.microsoft.com/Forums/en-US/3796da85-fbb4-4722-a5d0-724859f7d4ae/sql-report-viewer-web-part-not-displaying-report?forum=sharepointgeneralprevious
    Here is the one more duplicate thread link in same forum. So either you can merge both OR delete one.
    https://social.technet.microsoft.com/Forums/en-US/259d2586-ed4a-4f47-a808-877d4621d9f2/report-builder-30-sql-report-viewer-web-part-not-displaying-report-in-sharepoint?forum=sqlreportingservices
    [SharePoint Forum Moderator]
    Hemendra:Yesterday is just a memory,Tomorrow we may never see<br/> Please remember to mark the replies as answers if they help and unmark them if they provide no help

  • DM3.0 EA2: Settings for "View Details" are not saved

    Hi,
    normally I want to see only the attributes and keys in logical model.
    I can change the settings at "View Details" to "Attributes" and "Keys" and the view is changing. When I close data modeler, start it again and open the recend data model, the settings are again on default "All details".
    Is this the standard or should the view settings be saved?
    I am running Data Modeler on Windows XP with german localization and the JDK 1.6.0_11 from Oracle SQL Developer.
    Edited by: db-geek on 17.01.2011 08:17

    The settings for "View Details" are now saved and restored, when the data model is opened again.

  • Tool for viewing the relation between tables.

    Hi,
    I imported the schema dump in Oracle 10g R2 DB, there are about 800 plus tables in that schema. I would like to know the relataion between tables.So,What tools are available for viewing the relation between tables?. I have TOAD, and Oracles SQL Developer tolls, if there are any free tools for the same, please let me know the URLs.
    Regards,
    Sabdar Syed.

    Hmmm, for free, except what gave Eric earlier, not easy...
    Here already discuss about that :
    Re: Table Dependencies
    Nicolas.

  • How to open a database object for view/edit using a command (v. 3.2.20.09)

    How can I open a database object for view or edit using a command in Oracle SQL Deveveloper?
    I find browsing or search for object in a large database to be slow and too cumbersome.

    Shift-F4 (pop-up descrribe) on a table name in the worksheet will let you view table details, but there is no quick edit.
    You can use filters on the object browser to reduce the number of visible objects.

  • Can I define a SQL Server View to Oracle data?

    So I have a subset of data whose source of truth resides in an Oracle Database. Can I define a SQL Server View to retrieve this subset of data and make it available on the SQL Server side for say Reporting and SSRS? I think I also saw where they tend to
    prefer User-Defined functions as opposed to a view. If I define the view using an OPENQUERY, I have noticed that it seems to run FOREVER on the SQL Server side and returns pretty timely if I run in Oracle SQL Developer. Is there anything I can tweak to improve
    this timeliness or lack there of?
    And the whole reason I'd like to create a view of this Oracle data is so that I can take advantage of all the views and functions that we have created on the SQL Server side.
    Has anyone gone down this path and can offer some advice and web sites or YouTubes as to the best way to approach this?
    Thanks for your review and am hopeful for a reply while I keep Googling this.

    There are couple of ways by which you can connect and fetch the data
    OPENQUERY - which you are already using [uses linked server] -
    runs on remote server
    OPENROWSET - I would like to avoid this because it requires crenditials
    OPENDATASET - Similar issue like OPENROWSET
    Directly access linked server like LINKEDSERVER.DATABASE.SCHEMA.TABLE -
    runs on your local server
    Now, performance
    basically, they have the same performance advantages and disadvantages when connecting to remote server. But you can enhance it by 
    Avoiding data conversion 
    Using procedure on Oracle and then call it from SQL Server (due to compiled plan your result will be faster)
    Avoiding dealing with complex data types
    If you are dealing with large number of records, try using Oracle connector in SSIS. I found it working much better than SQL sometimes.
    Hope this will help
    Glad to help! Please remember to accept the answer if you found it helpful. It will be useful for future readers having same issue.
    My Profile on Microsoft ASP.NET forum

  • Adobe connect could not process this document for viewing

    I am using Connect 9 and trying to add a PDF to a share pod. These PDF's are sized at 11x17 and were converted from dwg  files. They are 2-4 megs in size. When I add them to a share pod I get the following error:
    "adobe connect could not process this document for viewing. Please try uploading the file again."
    Things I have already tried:
    Optimizing the PDF
    Printing the dwg file to a pdf
    Adding the pdf to my content library and then adding it to the share pod
    Reducing the page size
    Adding other PDF's to the meeting or pods work fine including larger sized files. My meeting is in 2 days and I can go with a screen share if I have too, but am working witha coulpe of novice presenters and want to make the process as easy for them as posible.
    Any help is appreciated.
    David

    I am having the exact same issue. It would be nice if there were a link to the remedy on this disucssion thread.
    EDIT: just found this - http://forums.adobe.com/message/5049521#5049521 will give it a try and see what happens.

Maybe you are looking for