April 16, 2013 at 5:23 pm
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?
April 16, 2013 at 6:50 pm
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.
April 16, 2013 at 7:44 pm
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
Change is inevitable... Change for the better is not.
April 16, 2013 at 11:59 pm
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
April 17, 2013 at 2:43 am
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.
April 17, 2013 at 10:12 am
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.
April 17, 2013 at 10:13 am
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.
Thanks, the night process actually use a web service not SSIS.
April 17, 2013 at 10:21 am
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
April 17, 2013 at 10:24 am
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.
April 17, 2013 at 10:33 am
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
Viewing 10 posts - 1 through 9 (of 9 total)
You must be logged in to reply to this topic. Login to reply