我正在尝试优化以下查询,并且只能进行10秒的筹码。我试图在连接中涉及的外键表列上应用非聚簇索引。 有人能让我知道我能做些什么来加快查询速度吗?
select
c.companyId,
c.companyName,
c.city,
cst.companyStatusTypeName,
ct.companyTypeName,
sc.simpleIndustryDescription,
c.officeFaxValue,
c.officePhoneValue,
c.streetAddress,
c.streetAddress2,
c.yearFounded,
c.zipCode,
c.webpage,
rep.templateTypeName,
rcg.isoCountry2,
rs.abbreviation
from ciqCompany c
inner join ciqCompanyStatusType cst on cst.companystatustypeid = c.companystatustypeid
inner join ciqCompanyType ct on ct.companyTypeId = c.companyTypeId
inner join refReportingTemplateType rep on rep.templateTypeId = c.reportingtemplateTypeId
inner join refCountryGeo rcg on c.countryId = rcg.countryId
inner join refState rs on rs.stateId = c.stateId
inner join ciqSimpleIndustry sc on sc.simpleIndustryId = c.simpleIndustryId
执行计划
表格定义
答案 0 :(得分:0)
尝试构建列存储索引:
https://docs.microsoft.com/en-us/sql/relational-databases/indexes/columnstore-indexes-data-warehouse
答案 1 :(得分:0)
查看执行计划,我发现密钥查找占用的时间最多 尝试使用该查询中的所有列创建索引 或者尝试在索引中使用包含的列。