Sql 有没有办法在索引扫描中转换此键查找?

Sql 有没有办法在索引扫描中转换此键查找?,sql,sql-server,indexing,sql-execution-plan,Sql,Sql Server,Indexing,Sql Execution Plan,我不是一个SQL专家(我努力完成工作——显然,越快越好),我不知道我给你的信息是否足以解决问题。我正在使用SQLServer,SQLServerManagementStudio 在本例中,我对“a”表和“o”表进行了联接查询 这两个表在一列上连接(假设o.customer=a.customer),但它们在另一列(o.opportunity)上分组,该列不在表a中 sum(case when a.ActivityTypeCode=4202 and a.actualend>o.createdo

我不是一个SQL专家(我努力完成工作——显然,越快越好),我不知道我给你的信息是否足以解决问题。我正在使用SQLServer,SQLServerManagementStudio

在本例中,我对“a”表和“o”表进行了联接查询

这两个表在一列上连接(假设o.customer=a.customer),但它们在另一列(o.opportunity)上分组,该列不在表a中

sum(case
when a.ActivityTypeCode=4202 and a.actualend>o.createdon
then 1
else 0 end)
as Feature_Name
这是查询中创建键查找的部分

查找的seek谓词表示:

Seek Keys[1]: Prefix: [MSCRMBauerMedia_MSCRM].[dbo].[ActivityPointerBase].ActivityId =
Scalar Operator([MSCRMBauerMedia_MSCRM].[dbo].[ActivityPointerBase].[ActivityId] as [a].[ActivityId])
我不知道谓词告诉我什么,也不知道这是如何进行索引搜索或索引扫描的。我对查询中涉及的所有变量都有索引:在单列上,覆盖所有变量的索引

有什么想法或建议吗

多谢各位

编辑:这是查询。附件是执行计划

select tp0.* from
(
select
 o.opportunityid
,(sum(
case when a.ActivityTypeCode=4202 and a.actualend>o.createdon
then 1
else 0
end
))  as Phone_calls
,(sum(
case when a.ActivityTypeCode=4210 and a.actualend>o.createdon
then 1
else 0
end
))  as Emails
from OpportunityBase as o
left join ActivityPointerBase as a
on o.customerid = a.regardingobjectid
where o.actualclosedate is null and a.RegardingObjectTypeCode=1
group by 
o.opportunityid
 ) as tp0

实际上,查看查询时,不需要左连接。请尝试内部联接。

我们到底要解决什么问题?性能差?它在查找什么(输出列)?它在寻找哪个指标?在哪张桌子上?我认为需要更多的查询和执行计划来提供一个合理的答案。我试图解决一个性能问题。现在我不在电脑上,我将很快发布整个查询和执行计划。我添加了剩余信息:查询和查询计划。查询运行需要多长时间?您希望它返回两个表中的多少行?使用内部联接而不是左联接是否重要?那么称为fndx_的ActivityPointerBase索引在cas中的作用如何呢。。。(含7%成本)定义?