Okay, here's my problem.
I have a massivley complicated query, that creates and populates two temp tables, then unions them - I want the output.
This is the easy bit - it takes about three minutes to crunch all this lot.
The problem arises when I either:
SELECT * FROM #Temp1
UNION ALL
SELECT * FROM #Temp2
or I
TRUNCATE tblOutput
INSERT INTO tlbOutput --all records must be current
SELECT * FROM #Temp1
UNION ALL
SELECT * FROM #Temp2
SELECT * FROM tblOutput
It takes over five minutes to bring back 50,000 rows.
I have created a key value on tblOutput, and have this as my PK_Index, but as I'm truncating this table each time, is this worthwhile? Is it worth having any other (clustered?) indexes on this table (there are no more single unique values, but combinations of fields are unique)? Is there any way I can get the output back faster?
Many thanks.
Andy Moss
I have a massivley complicated query, that creates and populates two temp tables, then unions them - I want the output.
This is the easy bit - it takes about three minutes to crunch all this lot.
The problem arises when I either:
SELECT * FROM #Temp1
UNION ALL
SELECT * FROM #Temp2
or I
TRUNCATE tblOutput
INSERT INTO tlbOutput --all records must be current
SELECT * FROM #Temp1
UNION ALL
SELECT * FROM #Temp2
SELECT * FROM tblOutput
It takes over five minutes to bring back 50,000 rows.
I have created a key value on tblOutput, and have this as my PK_Index, but as I'm truncating this table each time, is this worthwhile? Is it worth having any other (clustered?) indexes on this table (there are no more single unique values, but combinations of fields are unique)? Is there any way I can get the output back faster?
Many thanks.
Andy Moss