SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


view more efficient than before or not?


view more efficient than before or not?

Author
Message
sqlfriends
sqlfriends
Hall of Fame
Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)

Group: General Forum Members
Points: 3793 Visits: 4007
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?
matak
matak
SSC-Addicted
SSC-Addicted (449 reputation)SSC-Addicted (449 reputation)SSC-Addicted (449 reputation)SSC-Addicted (449 reputation)SSC-Addicted (449 reputation)SSC-Addicted (449 reputation)SSC-Addicted (449 reputation)SSC-Addicted (449 reputation)

Group: General Forum Members
Points: 449 Visits: 3946
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.
Jeff Moden
Jeff Moden
SSC Guru
SSC Guru (84K reputation)SSC Guru (84K reputation)SSC Guru (84K reputation)SSC Guru (84K reputation)SSC Guru (84K reputation)SSC Guru (84K reputation)SSC Guru (84K reputation)SSC Guru (84K reputation)

Group: General Forum Members
Points: 84537 Visits: 41064
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 for each 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%, Clustered Index scan: 41%
new version: Sort 53%, Clustered index scan 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.
If you think its expensive to hire a professional to do the job, wait until you hire an amateur. -- Red Adair

Helpful Links:
How to post code problems
How to post performance problems
Forum FAQs
GilaMonster
GilaMonster
SSC Guru
SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)

Group: General Forum Members
Points: 86172 Visits: 45229
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


rals
rals
SSCrazy
SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)

Group: General Forum Members
Points: 2169 Visits: 843
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

Regards,
Rals
.

sqlfriends
sqlfriends
Hall of Fame
Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)

Group: General Forum Members
Points: 3793 Visits: 4007
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.
sqlfriends
sqlfriends
Hall of Fame
Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)

Group: General Forum Members
Points: 3793 Visits: 4007
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.
sqlfriends
sqlfriends
Hall of Fame
Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)

Group: General Forum Members
Points: 3793 Visits: 4007
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 for each 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%, Clustered Index scan: 41%
new version: Sort 53%, Clustered index scan 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
Lynn Pettis
Lynn Pettis
SSC-Dedicated
SSC-Dedicated (38K reputation)SSC-Dedicated (38K reputation)SSC-Dedicated (38K reputation)SSC-Dedicated (38K reputation)SSC-Dedicated (38K reputation)SSC-Dedicated (38K reputation)SSC-Dedicated (38K reputation)SSC-Dedicated (38K reputation)

Group: General Forum Members
Points: 38891 Visits: 38508
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.

Cool
Lynn Pettis

For better assistance in answering your questions, click here
For tips to get better help with Performance Problems, click here
For Running Totals and its variations, click here or when working with partitioned tables
For more about Tally Tables, click here
For more about Cross Tabs and Pivots, click here and here
Managing Transaction Logs

SQL Musings from the Desert Fountain Valley SQL (My Mirror Blog)
GilaMonster
GilaMonster
SSC Guru
SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)

Group: General Forum Members
Points: 86172 Visits: 45229
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


Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search