我想知道使用表变量是否比使用内部联接(选择)的性能更高或更低
示例:
DECLARE @tab TABLE(Id int)
INSERT INTO @tab
SELECT Id
FROM SomeTable
WHERE SomeDate = "10 DAYS AGO"
SELECT *
FROM SomeOtherTable
INNER JOIN @tab t
ON SomeOtherTable.id = t.id
--VERSUS--
SELECT *
FROM SomeOtherTable
INNER JOIN (SELECT Id FROM SomeTable WHERE SomeDate = "10 DAYS AGO") t
ON SomeOtherTable.id = t.id
对于大型查询,如果您必须多次进行相同的连接,第一个更易于维护,但性能最高的是什么?
问候