Merge Join

Merge join is a strategy which sql servers takes up when condition on which the table is joined is a column which is ordered ; this happens when lets say that two table T1, T2 have columns T1C and T2C

T1C and T2C are the columns on which the tables are joined these both columns are ordered, so what sql serves does is it goes row by row and compares the elements from both the tables, wherever a miss match occurs that entry is discarded and the rest is returned.

What if there are multiple columns on which the conditions on which the table is to be joined, what sql server does is that it creates a temp table loads everything, if duplicates are there they are discarded.

Merge Join is the fastest algorithm that sql server has but can be very expensive when sort operation needs to be done as well.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s