SQL Server 2012性能问题 [英] SQL Server 2012 Performance Issue

查看:166
本文介绍了SQL Server 2012性能问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们的SQL Server 2012企业版设置存在性能问题我无法解释,我希望你们有个想法。

we have a performance issue with our SQL Server 2012 Enterprise setup that I am unable to explain and I am hoping you guys have an idea.

我们有一个事实表,我们聚合的一堆int列以及区域维度表。

We have a fact table with a bunch of int columns that we aggregate as well as a region dimension table.

这是我们的事实表的结构:

This is the structure of our fact table:


  • regionId(int)

  • 收入(十进制10,2)

  • orderIntake(十进制) 10,2)

这是维度表的结构:


  • worldRegion(varchar(100)9

  • cluster(varchar(100))

  • country(varchar(100) ))

  • regionId(int)

  • worldRegion(varchar(100)9
  • cluster (varchar(100))
  • country (varchar(100))
  • regionId (int)

事实表和维度表通过在regionId列上的INNER JOIN。只要我们不限制国家/地区,这种表现就相当不错。

The fact table and the dimension table are connected via a INNER JOIN over the regionId columns. The performance of this is quite good as long as we don't restrict the countries.

例如

SELECT SUM(收益)FROM factTable f INNER JOIN regionDim r O N f.regionId = r.regionId

快(<1秒)。

然而

SELECT SUM(收益)FROM factTable f INNER JOIN regionDim r ON f.regionId = r.regionId WHERE r.country IN('France','Germany')

相当慢(> 8秒),大约有500k记录。

is pretty slow (> 8 sec) for around 500k records.

我们确实有以下指标:


  • 关于regionId上事实表的ColumnStore索引专栏

  • 维度表上的聚簇索引(regionId,country,cluster,worldRegion)

是我们可以从索引或整体结构的角度来改变吗?

Is there anything that we can change from either an index or an overall structure point of view?

推荐答案

索引中列的顺序dim表的不允许在第二个查询的where子句中使用此索引。这是因为行由第一个索引列(regionId)索引,然后由第二个(国家/地区)索引,依此类推。仅使用第二列就像在使用名字搜索某人时使用电话簿。
尝试在country列上添加一个单独的索引,看看性能是否有所改善。

The order of columns in the index of the dim table does not allow using this index in the where clause of the 2nd query. This is because the rows are indexed by the 1st index column (regionId), then by the 2nd (country) and so on. Using only the 2nd column is like using a phone book when searching for someone by the first name only. Try putting a separate index on the country column and see if performance improves.

这篇关于SQL Server 2012性能问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆