Sql-server – parallelism repartitions, ordering, and hash matches

sql-server-2008

I am just starting to delve into query plans and recently learned that "hash matches" are bad. I know it's rare for something to be so absolute, though, and I want to determine if I have a bad hash match.

My query, which includes two tables, uses parallelism. It uses clustered index seeks on the two tables then it goes to the step Parallelism (Repartition Streams) with partitioning type of hash after both of these seeks. For one table, a bitmap is created and then these two are joined (inner join) by hash match.

My understanding is if the data to be joined is ordered, a merge join would be used – and this is preferable. The clustered indexed seek is ordered.

So… I guess I'm just looking for some information on this situation. Do hash matches always follow repartitions of streams? Does that repartition ignore order? Or should I not be bothered by this "evil" hash match?

Thank you!!

Best Answer

Hash matches are not necessarily bad @ all. Please see Grant Fritchey's awesome (and free!) book: SQL Server Execution Plans