DBAsupport.com Forums - Powered by vBulletin
Results 1 to 9 of 9

Thread: Performance Issue with View and Query

  1. #1
    Join Date
    Feb 2004
    Location
    Mumbai, Maharastra
    Posts
    67

    Question Performance Issue with View and Query

    Hi,

    I have a sql statement which retreives rows of around 13000+ records in 3 secs.
    I created a view out of the same sql statement and when i access the view it retreives the same no of records in 4 min.
    Can any one put come light on as to what would be the problem.
    Regards,
    Surajit K Mitra

  2. #2
    Join Date
    May 2005
    Location
    Toronto Canada
    Posts
    57
    A view is just a stored sql statement, it will run att he same speed as the sql statement it is based on.

    Post a cut and paste of the SQL query alone showing it running in three seconds, the create view statement, then a query against the view showing 4 minutes. My bet would be that you are not comparing apples to apples. The only fair comparision is along the lines of:

    Code:
    SELECT * FROM t;
    CREATE VIEW v AS SELECT * FROM t;
    SELECT * FROM v;
    If you are doing anything different, then the problem lies in how you are accessing the view.

    John

  3. #3
    Join Date
    Feb 2004
    Location
    Mumbai, Maharastra
    Posts
    67
    Hi John,

    look at the attachment and comment pls.
    Attached Images Attached Images
    Regards,
    Surajit K Mitra

  4. #4
    Join Date
    May 2005
    Location
    Toronto Canada
    Posts
    57
    Interesting. Try removing the ALL ROWS hint from NOT EXISTS query. It is superflous anyway, and I seem to recall that there are occasionally issues with hints in views.

    If that doesn't fix things, post the explain plans and statistics for the plain statement and for the view.

    John

  5. #5
    Join Date
    Nov 2002
    Location
    Geneva Switzerland
    Posts
    3,142
    I'd start by looking at the timings in SQL*Plus. (TOAD? will have to wrap its own code around yours for display purposes - this might be causing a problem.)
    "The power of instruction is seldom of much efficacy except in those happy dispositions where it is almost superfluous" - Gibbon, quoted by R.P.Feynman

  6. #6
    Join Date
    Feb 2004
    Location
    Mumbai, Maharastra
    Posts
    67
    Execution of sql script from either TOAD or SQL*Plus didnt made a huge difference.
    I debugged the view and i found if i remove the ROWNUM clause then the query fetches records exactly as desired. Now, this is major problem for me now .
    Can anyone put some light on this.
    I am adding the sql queries along with this.
    Attached Files Attached Files
    Last edited by surajitmitra78; 07-21-2005 at 09:08 AM.
    Regards,
    Surajit K Mitra

  7. #7
    Join Date
    Feb 2004
    Location
    Mumbai, Maharastra
    Posts
    67
    Can anyone comment on this and come with some hints or probable solution
    Regards,
    Surajit K Mitra

  8. #8
    Join Date
    Feb 2004
    Location
    Mumbai, Maharastra
    Posts
    67
    Hey! DaPI do you have anything to solve this problem.
    Regards,
    Surajit K Mitra

  9. #9
    Join Date
    May 2000
    Location
    ATLANTA, GA, USA
    Posts
    3,135
    Trace the sql and post the tkprof output for both queries.

    Tamil

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width