|
Dear All, I need help on one of the query. My execution plans shows Index Scan in spite of using the Indexed Column in the Join predicate. I have two tables and one is 35 million and another one with 10K rows. I am trying to do a left outer join and my execution plans shows up Hash Match with Index Scan. I am not sure on how to improve this query. Also, my statistics are updated. Please can someone help on this issue? Many thanks in advance. Cheers - DV
(comments are locked)
|
|
Hash match is common if the inputs are unsorted, so the optimizer needs to build a hash table and probe it from the other table, rather than use the 'faster' merge join. What indexes are on these tables? And can you post the execution plan, either as an image or as XML? I had a quick look before you removed the pasted XML plan, and there seemed to be a datatype conversion on the Based on what you have said below, and the amount of data being processed, the hash match may be the best operator. The reason for the index scan, rather than the index seek is simply because you have no Sorry for the mess with the XML excecution plan. I understand its hard to read, but I am unable to attach the execution plan image here. Sorry :(
Nov 01 '11 at 08:40 AM
OnlyGraphite
what are the datatypes of
Nov 01 '11 at 08:52 AM
Kev Riley ♦♦
Test_Sales.Sector is NVarchar(8) and Test_Risk_Factor.Sector is Varchar(50)
Nov 01 '11 at 08:55 AM
OnlyGraphite
This query is taking 5 hours to complete and it is way too long to complete. :(
Nov 01 '11 at 08:56 AM
OnlyGraphite
Well it is returning 35 million rows...... Where is the data going to? It can't possibly be being returned to an application for viewing by a user! Try changing the datatypes (on your test system) to match - see if that changes the query plan.
Nov 01 '11 at 09:00 AM
Kev Riley ♦♦
(comments are locked)
|


Is Test_Sales the 35 million one, and Test_Risk_Factor the 10k one?
Yes, that's correct.
Hi Again,
Sorry for not providing this information earlier. Here you go...
Test_Sales.Productinterfacestorageid – Clustered Index
Test_Sales.Sector – Non Clustered Index with Included Column (PostCode)
Test_Risk_Factor.Sector – Clustered Index
Thanks again for your help.
Cheers - DV