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.
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)
- revenue (Decimal 10,2)
- orderIntake (Decimal 10,2)
And this is the structure of our dimension table:
- worldRegion(varchar(100)9
- cluster (varchar(100))
- country (varchar(100))
- regionId (int)
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.
E.g.
SELECT SUM(revenue) FROM factTable f INNER JOIN regionDim r ON f.regionId=r.regionId
is fast (<1 sec).
However
SELECT SUM(revenue) FROM factTable f INNER JOIN regionDim r ON f.regionId=r.regionId WHERE r.country IN ('France','Germany')
is pretty slow (> 8 sec) for around 500k records.
We do have the following indizes in place:
- ColumnStore Index on the fact table on the regionId column
- Clustered Index on dimension table (regionId,country,cluster,worldRegion)
Is there anything that we can change from either an index or an overall structure point of view?