Hi all,
Hopefully somebody can help me with this but basically I have a stored procedure that I'm trying to speed up a little bit. This with SQL Server 2005. Right now, it's running 45 seconds in situation #1. In situation #2, it's running about 44 seconds.
Situation #1:
1) Create temporary table.
2) Populate temporary table by a INSERT INTO with a SELECT
3) Update temporary table (using the temporary table field in the WHERE clause.)
4) Select all from temporary table (i.e. *)
Situation #2:
1) Create temporary table
2) Create non-clustered index on one field in the temporary table.
3) Populate temporary table by a INSERT INTO with a SELECT
4) Invoke a child stored procedure.
4a) Child SP - Performs the UPDATE (using a temporary table indexed field in the WHERE clause.)
4b) Child SP - Selects all from the temporary table (i.e. *)
The query plan on situation #2 is NOT showing the index of the temporary table being used but rather a table scan.
The volume of the query in both cases returns 177,000+ rows.
So, I would expect with that volume and the situation #2, that optimizer would know the index exists due to the child stored procedure. But it's yielding the same as situation #1.
Any body have any ideas; is there something I'm missing?
Hopefully somebody can help me with this but basically I have a stored procedure that I'm trying to speed up a little bit. This with SQL Server 2005. Right now, it's running 45 seconds in situation #1. In situation #2, it's running about 44 seconds.
Situation #1:
1) Create temporary table.
2) Populate temporary table by a INSERT INTO with a SELECT
3) Update temporary table (using the temporary table field in the WHERE clause.)
4) Select all from temporary table (i.e. *)
Situation #2:
1) Create temporary table
2) Create non-clustered index on one field in the temporary table.
3) Populate temporary table by a INSERT INTO with a SELECT
4) Invoke a child stored procedure.
4a) Child SP - Performs the UPDATE (using a temporary table indexed field in the WHERE clause.)
4b) Child SP - Selects all from the temporary table (i.e. *)
The query plan on situation #2 is NOT showing the index of the temporary table being used but rather a table scan.
The volume of the query in both cases returns 177,000+ rows.
So, I would expect with that volume and the situation #2, that optimizer would know the index exists due to the child stored procedure. But it's yielding the same as situation #1.
Any body have any ideas; is there something I'm missing?