Showing posts with label perform. Show all posts
Showing posts with label perform. Show all posts

Tuesday, March 27, 2012

ForEach Loop Container

I am using a SQL Task to load the data needed for the loop into a variable, then using a script task to perform calculations. Is it possible to update a table from the script task with the calculated values?.

Thanks
You can use System.Data and ADO.Net inside a script task. You could even use an ADO.Net connection manager. Just write some normal VB.Net code to do your data access.

I don't know what you are doing, but I would question this method. Why not do it all in a single SQL Task? Why use a SQL task to do the update? Why not do it all in a script task?|||I want to test the performance difference between a cusor in sql 2000 and the loop in sql2005.|||

I wouldn't recommend that as a use of SSIS... instead, consider revisiting what you do with the cursors to be done using the data flow task.

regards,
ash

|||Let me explain what I am trying to do. I have +/- 600 performance reports to calculate each with 40 odd items. If I'm on the wrong path please point me in the right direction. I would appreciate any help.|||

Do all performance reports have the same structure just different data? Are all the calculations identical as well?

I'm intruiged by the problem and can work with you on how to do this in most efficient manner, we can then let the group know what we found.

regards,
ash

|||

Yes the structure for all reports are the same, the calculations are dependant on the specific measure.

May I contact you offline and not involve the forum until a suggestion is ready

Sunday, February 26, 2012

FOR SELECT

In another database that I've used, I found the FOR SELECT syntax
handy. It allows a stored procedure to perform actions for each
record returned by the select statement. I can't find the
documentation on this in SQL Server. Am I missing something here?
I've just started with this product, so it won't surprise me to find
that it's right in front of my face, so to speak or that another
syntax performs the same function.

Thanks for any help with this.Weaver (we.aver@.verizon.net) writes:
> In another database that I've used, I found the FOR SELECT syntax
> handy. It allows a stored procedure to perform actions for each
> record returned by the select statement. I can't find the
> documentation on this in SQL Server. Am I missing something here?
> I've just started with this product, so it won't surprise me to find
> that it's right in front of my face, so to speak or that another
> syntax performs the same function.

Well, there is:

DECLARE mycur CURSOR FOR
SELECT Orders FROM Orders WHERE ...

So it is not a stored procedure, but just a bunch of statments.

However, cursors and other iterative solutions are in very most cases
inferior in perfomance than set-based statements, so you should avoid
them.

--
Erland Sommarskog, SQL Server MVP, sommar@.algonet.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp|||> However, cursors and other iterative solutions are in very most cases
> inferior in perfomance than set-based statements, so you should avoid
> them.

Thanks for the info. Pretty much like the FOR syntax.

What degree of performance hit are we talking about here? Have you
seen any stats on this?|||Weaver (we.aver@.verizon.net) writes:
> What degree of performance hit are we talking about here? Have you
> seen any stats on this?

Depends on the number of rows involved. For a handful it may not be
noticeable. If you have ten thousand rows, an iterative solution may
take 30 seconds when a set-based runs subsecond.

With other words: the performance hit can be huge.

--
Erland Sommarskog, SQL Server MVP, sommar@.algonet.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp|||I did some experiments a while back, using 2 10,000 record lookups
into a 1million record dataset. Teh set based solution took a while,
several minutes. A semi set semi cursor solution took over half an
hour. The full nested cursor solution - well I killed it after
1/2hour. It had got less than 1% through the dataset...
draw your own conclusions :)

Erland Sommarskog <sommar@.algonet.se> wrote in message news:<Xns94F55EB3E8181Yazorman@.127.0.0.1>...
> Weaver (we.aver@.verizon.net) writes:
> > What degree of performance hit are we talking about here? Have you
> > seen any stats on this?
> Depends on the number of rows involved. For a handful it may not be
> noticeable. If you have ten thousand rows, an iterative solution may
> take 30 seconds when a set-based runs subsecond.
> With other words: the performance hit can be huge.|||> With other words: the performance hit can be huge.

OK! I'll run some tests on this before I run off and design something around it.

Thanks again for the help.|||WangKhar wrote:
> I did some experiments a while back, using 2 10,000 record lookups
> into a 1million record dataset. Teh set based solution took a while,
> several minutes. A semi set semi cursor solution took over half an
> hour. The full nested cursor solution - well I killed it after
> 1/2hour. It had got less than 1% through the dataset...
> draw your own conclusions :)

I'm sure the set-based version was fastest, but it may not be by
as much as it seems. The indexing will make a lot less difference
on the set-based version, because you're not faced with doing a
table scan (or a filter, if the index doesn't narrow it down much)
for every single row.

Bill|||It was properly indexed...

William Cleveland <WCleveland@.Ameritech.Net> wrote in message news:<9zxtc.22686$qt1.14178@.newssvr31.news.prodigy.com>...
> WangKhar wrote:
> > I did some experiments a while back, using 2 10,000 record lookups
> > into a 1million record dataset. Teh set based solution took a while,
> > several minutes. A semi set semi cursor solution took over half an
> > hour. The full nested cursor solution - well I killed it after
> > 1/2hour. It had got less than 1% through the dataset...
> > draw your own conclusions :)
> I'm sure the set-based version was fastest, but it may not be by
> as much as it seems. The indexing will make a lot less difference
> on the set-based version, because you're not faced with doing a
> table scan (or a filter, if the index doesn't narrow it down much)
> for every single row.
> Bill