I have a script which contains a "work" table that was being generated as it ran (via INTO).
Later queries which used the table ran too slow so I added CREATE INDEX statements on the work table.
This had no effect. So I made the work table permanent and added the indexes before the script runs, deleting all rows at the beginning of the script.
Now I see the performance improvement.
So this leads to the conclusion that the script is being compiled/pre-processed before it runs and that indexes created during the run are not used.
Can someone with specific knowledge confirm this?
The script is being run by an Execute SQL task in SSIS if that makes a difference.
Thx.
Later queries which used the table ran too slow so I added CREATE INDEX statements on the work table.
This had no effect. So I made the work table permanent and added the indexes before the script runs, deleting all rows at the beginning of the script.
Now I see the performance improvement.
So this leads to the conclusion that the script is being compiled/pre-processed before it runs and that indexes created during the run are not used.
Can someone with specific knowledge confirm this?
The script is being run by an Execute SQL task in SSIS if that makes a difference.
Thx.