Performance difference between NOT Exists and LEFT JOIN IN SQL Server -


I can have the following questions to check the existing records in the target table.

  * Choose from table 1 where the column is not 1 (Select column 2 from Table 2) Select from Table 1 * Join table 2, where Table 1 Column 1 = Table 2. Column 2 Where Table 2 ID column is zero  

I want to know which query has a better performance.

Go to not present generally.

This is in not in , if columns are tapable on both sides (and you have the desired words that you probably want)

left Join ... The tap sometimes combines with the latter filter to preserve the matching rows and can be very less efficient.

An example showing this is below no scheme and the plan to be excluded for being included in more than 1 million rows in the filter How to blow in.

does not exist

enter image details here

External participant ... NULL

Enter image details here < / P>

no

Enter image details here

< Pre> create table table 1 (IDCOLM INT identity primary key, column 1 ENTNLL, filler CHAR (8000) zero, unique (column 1, IDC column)); Table Table 2 (IDCOLM INT Identity Primary Key, Column 2 INT Zero, Filler CHAR (8000) Zero, Unique (Column 2, ID Column)); Include in Table 2 (column2). Include in column 1. In column 1 (column1) Master's selection number% 5 from Master ... Automatically select * from Table 1 T1 where not present (selection * from Table 2 T2 where T2. Column 2 = T 1. Column 1) SELECT * FROM Select Table 1 where the column 1 is not (Select Table 2 to Table 2) Table 1 * 1 of Table 1 Add Table 2 to Table 2. Column 1 = Table 2. Column 2 Where Table 2 IDCollum Null Drop Table Table 1, Table 2

Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -