If you look around on "Ask Tom", you find him saying that this is exactly the situation where comparing "costs" is pretty meaningless. As far as I understand him the only time when we (as opposed to the CBO) should look at them is when comparing the same query at a given moment with different hints - i.e. when doing the job of the CBO!
1. I have created table with some no. of rows and created one index on one of the columns. And I use this column in one of the select queries. I have execution plan for this.
2. I have updated the indexed column many times in between. So, index has grown in size. Still the execution plan for the select statement mentioned in above shows same.
3. Now, I analyze the table (so the indexes get...) and populate the dictionary with new statistics. Now, I am taking the execution plan for the select query used in step 1. It shows with higher cost as the size of index is increased as per the detail available to optimizer.
4. Now, I rebuild the index and it has been reduced to its origional size. I analyze analyze the index now and populate the dictionary with latest statistics. I am getting execution plan for select statement used in step 1 and it has different cost. It's likely that the new cost could of lesser than what we got in step 3.
Dilippatel isn't getting a different execution plan -- he just wanted to know why the cost had changed. I don't think he has any problem other than understanding why this is so, and it seems like rebuilding indexes isn't apropriate to his situation.
Bookmarks