English 中文(简体)
最好是在联合询问中询问科索沃武装部队或科索沃武装部队。
原标题:Is it better to query on the FK or the PK in a join query

使用2k5和假定[ID]栏,是四组的PK,[FK......]K栏有两种查询的无分类索引,WHERE条款的效益更高?

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

页: 1

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

是否比其他更好? 业绩差别是否值得一提?

最佳回答

a 包括:

SET SHOWPLAN_ALL ON

然后处理您的询问。 它将显示质询的执行计划,而不是结果套。

我在座标上显示完全相同的执行计划。 无论你如何执行,执行计划将取得最佳效果。 然而,我要说的是第一种版本,因为人类阅读你的意图就更清楚了。

问题回答

i 认为这两种方式之间存在任何相关的业绩差异。





相关问题
What to look for in performance analyzer in VS 2008

What to look for in performance analyzer in VS 2008 I am using VS Team system and got the performance wizard and reports going. What benchmarks/process do I use? There is a lot of stuff in the ...

SQL Table Size And Query Performance

We have a number of items coming in from a web service; each item containing an unknown number of properties. We are storing them in a database with the following Schema. Items - ItemID - ...

How to speed up Visual Studio 2008? Add more resources?

I m using Visual Studio 2008 (with the latest service pack) I also have ReSharper 4.5 installed. ReSharper Code analysis/ scan is turned off. OS: Windows 7 Enterprise Edition It takes me a long time ...

Manually implementing high performance algorithms in .NET

As a learning experience I recently tried implementing Quicksort with 3 way partitioning in C#. Apart from needing to add an extra range check on the left/right variables before the recursive call, ...

How do I profile `paster serve` s startup time?

Python s paster serve app.ini is taking longer than I would like to be ready for the first request. I know how to profile requests with middleware, but how do I profile the initialization time? I ...

热门标签