view more efficient than before or not?

  • I have a view, if we runs it individually in SSMS, it runs ok, but we have a batch process at night that uses it for each individual. so overall it makes the process slow.

    Now we change the view to hopefully speed it up. But I would like to compare with older version ,

    which version runs faster. By running both of them in SSMS, I cannot see much difference, is there a way to see which view cost less time?

    I run it in SSMS with Execution plan, I see in :

    older version: Sort cost : 58%, Clustered Index scan: 41%

    new version: Sort 53%, Clustered index scan 47%

    So their total is all 100%, so how can I know which one is more efficient ?

    I know we probably can figure that out by running our overnight process, but it usually takes more thatn 3 hours to find out?

  • There really isnt much information to go on here.

    If you can post the ACTUAL execution plans and the definitions for both views that would be a start.

  • sqlfriends (4/16/2013)


    Now we change the view to hopefully speed it up.

    ...but we have a batch process at night that uses it [font="Arial Black"][highlight=""]for each [/highlight][/font]individual. so overall it makes the process slow.

    I believe that changing the view might not do any good. I've highlighted the problem that I think is the real problem above.

    I run it in SSMS with Execution plan, I see in :

    older version: Sort cost : 58%, [font="Arial Black"][highlight=""]Clustered Index scan[/highlight][/font]: 41%

    new version: Sort 53%, [font="Arial Black"][highlight=""]Clustered index scan [/highlight][/font]47%

    Perhaps you don't understand that a Clustered Index Scan is really nothing more than a Table Scan. That's what you need to work on first and then you need to work on the "for each" problem.

    If you really want help with a performance problem, then read the article at the 2nd lik in my signature below.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • sqlfriends (4/16/2013)


    I have a view, if we runs it individually in SSMS, it runs ok, but we have a batch process at night that uses it for each individual. so overall it makes the process slow.

    You've tested and benchmarked and confirmed that the view is absolutely the problem with the batch process?

    Now we change the view to hopefully speed it up. But I would like to compare with older version ,

    which version runs faster. By running both of them in SSMS, I cannot see much difference, is there a way to see which view cost less time?

    Run the queries, compare the execution characteristics (via Profiler or the statistics settings). The plan's costings do not tell you how long it will run.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • Batch process means SSIS package ?

    If you are using SSIS, recently I came across a situation that extracting data using a view from SSIS slower but running the same view in SSMS is faster.

    "SSIS - views as data source - very poor performance or SSIS hangs".

    Please refer the below links.

    http://connect.microsoft.com/SQLServer/feedback/details/258901/ssis-views-as-data-source-very-poor-performance-or-ssis-hangs

    http://blogs.msdn.com/b/sqlperf/archive/2007/04/29/set-up-ole-db-source-to-read-from-view-efficiently.aspx

    [font="Verdana"]Regards,
    Rals
    [/font].
  • GilaMonster (4/16/2013)


    sqlfriends (4/16/2013)


    I have a view, if we runs it individually in SSMS, it runs ok, but we have a batch process at night that uses it for each individual. so overall it makes the process slow.

    Yes, we changed the view at first to accommdate other data change, it slows down the night process. That is why we know it is the view. Then we tried to optmimize the view.

  • rals (4/17/2013)


    Batch process means SSIS package ?

    If you are using SSIS, recently I came across a situation that extracting data using a view from SSIS slower but running the same view in SSMS is faster.

    "SSIS - views as data source - very poor performance or SSIS hangs".

    Please refer the below links.

    http://connect.microsoft.com/SQLServer/feedback/details/258901/ssis-views-as-data-source-very-poor-performance-or-ssis-hangs

    http://blogs.msdn.com/b/sqlperf/archive/2007/04/29/set-up-ole-db-source-to-read-from-view-efficiently.aspx

    Thanks, the night process actually use a web service not SSIS.

  • Jeff Moden (4/16/2013)


    sqlfriends (4/16/2013)


    Now we change the view to hopefully speed it up.

    ...but we have a batch process at night that uses it [font="Arial Black"][highlight=""]for each [/highlight][/font]individual. so overall it makes the process slow.

    I believe that changing the view might not do any good. I've highlighted the problem that I think is the real problem above.

    I run it in SSMS with Execution plan, I see in :

    older version: Sort cost : 58%, [font="Arial Black"][highlight=""]Clustered Index scan[/highlight][/font]: 41%

    new version: Sort 53%, [font="Arial Black"][highlight=""]Clustered index scan [/highlight][/font]47%

    Perhaps you don't understand that a Clustered Index Scan is really nothing more than a Table Scan. That's what you need to work on first and then you need to work on the "for each" problem.

    If you really want help with a performance problem, then read the article at the 2nd lik in my signature below.

    We know it is the sort part makes it slower, but it seems we don't have any choice.

    For clustered index scan, because this is a view of schema binding, it uses the index , the index is the PK of the underlying table, I don't know why view make it to index scan not index seek

  • Unfortunately, without seeing the the DDL for the view and the underlying table(s) and their indexes, plus how the view is being called I don't see how much more we can actually do to help. Anything we provide at this point will be nothing more than shots in the dark.

  • sqlfriends (4/17/2013)


    For clustered index scan, because this is a view of schema binding

    Schema binding does not cause table scans.

    Please post table definitions, index definitions and execution plan, as per http://www.sqlservercentral.com/articles/SQLServerCentral/66909/

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass

Viewing 10 posts - 1 through 9 (of 9 total)

You must be logged in to reply to this topic. Login to reply