在MS SQL Server中为巨大查询创建索引

时间:2015-05-28 16:19:41

标签: sql-server tsql

我有以下巨大的要求:

$dia = 'P1D';
$data_desban = new DateTime($desde);
$data_desban->add(new DateInterval($dia));
echo $data_desban->format("Y-m-d H:i:s");

SELECT TOP (100000) B.UserId AS [UserId], B.ProfileId AS [ProfileId] FROM tBounce AS B JOIN tBounceType AS BT ON BT.Id = B.BounceTypeId WHERE BT.IsHard = 1 AND B.IsProcessedByAutoUnsubscriber = 0 GROUP BY B.UserId, B.ProfileId HAVING count(*) > 2 表包含数十亿条记录,我需要在索引中包含哪些列?我还需要添加分组字段吗?

0 个答案:

没有答案