TI - SQL Query with JOIN or View, Slow to Execute
Posted: Wed Nov 16, 2011 8:22 am
Hi,
I have a process that needs to run a SQL query that contains a JOIN. The query is simple enough:
SELECT *
FROM TableA AS a
INNER JOIN
TableB AS b
ON a.OrderNumber = b.DocNumber AND a.SKUKey = b.SKUKey
AND a.DateKey >= '20111002' AND a.DateKey <= '20111105'
If I run this query in SQL Server Manager it returns about 4,000 rows of data in 4 seconds. However if I run this TI Process it takes about 6,000 seconds. I have taken out all the code in the Data and Metadata tabs for testing purposes, so this Process is only executing one line of code which is counter = counter + 1; ASCIIoutput counter. I left this in so the process has something to do.
My understanding is that the TI Process will simply pass the query on so it should not matter what is in the query as long as SQL can do it. I have created a view using this query and referenced the view in the TI with no effect. However if I create a new table using the above query and reference this new table, the process executes in a couple of seconds.
Any ideas ?
Thanks.
I have a process that needs to run a SQL query that contains a JOIN. The query is simple enough:
SELECT *
FROM TableA AS a
INNER JOIN
TableB AS b
ON a.OrderNumber = b.DocNumber AND a.SKUKey = b.SKUKey
AND a.DateKey >= '20111002' AND a.DateKey <= '20111105'
If I run this query in SQL Server Manager it returns about 4,000 rows of data in 4 seconds. However if I run this TI Process it takes about 6,000 seconds. I have taken out all the code in the Data and Metadata tabs for testing purposes, so this Process is only executing one line of code which is counter = counter + 1; ASCIIoutput counter. I left this in so the process has something to do.
My understanding is that the TI Process will simply pass the query on so it should not matter what is in the query as long as SQL can do it. I have created a view using this query and referenced the view in the TI with no effect. However if I create a new table using the above query and reference this new table, the process executes in a couple of seconds.
Any ideas ?
Thanks.