August 16, 2013 at 5:05 pm
I have a simple query, if i run that query from SSMS it takes about 10 mins and if i run the same query as a exec sql task inside SSIS package takes less than 3 mins? I am clearing the buffers after each execution, and yes the source connection strings are the same. I am logged in the server and testing using SSMS and SSIS. Is there any reason why it is faster from SSIS? Query returns about 20 million records
SELECT * FROM vwActivities WHERE
CreatedDateKey>=20130101 and Fde='A123'
August 17, 2013 at 6:33 am
20 million rows? It will take SSMS quite some time to render all those rows, particularly if you have results set to grid!
[font="Times New Roman"]Erland Sommarskog, SQL Server MVP, www.sommarskog.se[/font]
August 17, 2013 at 7:40 am
Short answer: SSMS is incredibly inefficient at displaying rows.
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
August 17, 2013 at 7:09 pm
curious_sqldba (8/16/2013)
I have a simple query, if i run that query from SSMS it takes about 10 mins and if i run the same query as a exec sql task inside SSIS package takes less than 3 mins? I am clearing the buffers after each execution, and yes the source connection strings are the same. I am logged in the server and testing using SSMS and SSIS. Is there any reason why it is faster from SSIS? Query returns about 20 million records
SELECT * FROM vwActivities WHERE
CreatedDateKey>=20130101 and Fde='A123'
I guess I'd have to ask where you're putting the results for that query because I sure can't imagine returning 20 million rows to the screen... ever! I guess I'd also be curious why you're using an integer to represent a date/time unless the intent is to export to a file.
--Jeff Moden
Change is inevitable... Change for the better is not.
August 18, 2013 at 9:24 am
curious_sqldba (8/16/2013)
I have a simple query, if i run that query from SSMS it takes about 10 mins and if i run the same query as a exec sql task inside SSIS package takes less than 3 mins? I am clearing the buffers after each execution, and yes the source connection strings are the same. I am logged in the server and testing using SSMS and SSIS. Is there any reason why it is faster from SSIS? Query returns about 20 million records
SELECT * FROM vwActivities WHERE
CreatedDateKey>=20130101 and Fde='A123'
A SELECT * query is also extremely inefficient. You are returning 20m rows and SQL Server has to touch every row and every field inorder to return the results you are looking for.
Have you used the SQL Profiler to see if the execution plans Show up anything obvious? In this case I would suggest performing a server-side trace because I could easily imagine running the query inside the GUI (in your case the SSMS) is affecting the Overall Performance of the query.
August 18, 2013 at 11:16 am
Even if it coud be done efficiently, I'd still like to know why someone is building a result set that contains 20 million rows.
--Jeff Moden
Change is inevitable... Change for the better is not.
August 18, 2013 at 11:27 am
Jeff Moden (8/18/2013)
Even if it coud be done efficiently, I'd still like to know why someone is building a result set that contains 20 million rows.
So Curious_sqldba did mention that he also ran the query in SSIS. I assume that he exporting the data. For which, of course, SSMS is not a good tool.
[font="Times New Roman"]Erland Sommarskog, SQL Server MVP, www.sommarskog.se[/font]
August 18, 2013 at 12:12 pm
Erland Sommarskog (8/18/2013)
Jeff Moden (8/18/2013)
Even if it coud be done efficiently, I'd still like to know why someone is building a result set that contains 20 million rows.So Curious_sqldba did mention that he also ran the query in SSIS. I assume that he exporting the data. For which, of course, SSMS is not a good tool.
Agreed... that's why I hate to assume and asked the question.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 8 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply