Hello, I rebuilt all the nonclustered indexes on the 2 tables (7 in one table and 2 in the other), I did not rebuild the clustered indexes. I ran update index statistics on the 2 tables afterwards. Then I ran the trace etc and it is still using the "bad" plan and the output looks identical. Unless I need to rebuild the clustered indexes too? They are not referenced in the plan. The data in the tables are not identical between the "good" server and the "bad" server, perhaps the data in these columns have an enormous amount of duplicates on the "bad" server?
Additionally, I forced the use of the index on the "bad" server and the query uses the good plan and runs instantly. So it works well if it uses the better plan, but I don't know why I still can't get the optimizer to choose that plan on its own.
Thanks!