使用SQL2k5並假定[ID]列是聚簇PK並且[FK ...]列有兩個查詢中的非聚簇索引, WHERE子句更有效率?在聯合查詢中查詢FK或PK更好嗎
SELECT *
FROM [table1]
INNER JOIN [table2] ON [table2].[ID] = [table1].[FK_table2]
INNER JOIN [table3] ON [table3].[ID] = [table1].[FK_table3]
WHERE
[table1].[FK_table2] = @table2_id
AND [table1].[FK_table3] = @table3_id
OR
SELECT *
FROM [table1]
INNER JOIN [table2] ON [table2].[ID] = [table1].[FK_table2]
INNER JOIN [table3] ON [table3].[ID] = [table1].[FK_table3]
WHERE
[table2].[ID] = @table2_id
AND [table3].[ID] = @table3_id
是一個比較理想的或比其他的更好嗎?性能差異是否會在一個之上引人注目?
是table11真的是table1的拼寫錯誤嗎? – 2010-09-20 18:53:33