Aggregation Designs in SQL Server Analysis Services

Aggregation designs are a fundamental concept in SQL Server Analysis Services (SSAS) for optimizing query performance in multidimensional models. By pre-calculating and storing aggregated data, you can significantly speed up the retrieval of frequently accessed data, especially for large cubes.

What are Aggregation Designs?

A cube contains detailed transactional data. When users query a cube, SSAS must often aggregate this detailed data on the fly to provide answers. This aggregation process can be time-consuming for complex queries or large datasets.

Aggregation designs allow you to define subsets of aggregated data that are stored physically within the cube. These aggregations are typically at higher levels of dimension hierarchies or cover common query patterns. When a query is executed, SSAS checks if the requested data can be satisfied by the pre-aggregated data in an aggregation design. If so, the query is answered much faster than if it had to be aggregated from the detail level.

Benefits of Using Aggregation Designs

Creating Aggregation Designs

Aggregation designs are typically created using SQL Server Data Tools (SSDT) or by scripting using MDX or XMLA.

Steps in SSDT:

  1. Open your SSAS project in SQL Server Data Tools.
  2. Navigate to the Browser tab for your cube.
  3. Right-click on the cube name and select New Aggregation Design.
  4. In the Aggregation Design wizard:
    • Select Cubes and Measures: Choose the cube and measures you want to create aggregations for.
    • Select Aggregation Options: You can choose between Full processing (generates all possible aggregations) or Rely on the wizard (SSAS suggests aggregations based on usage patterns or defined rules).
    • Define Aggregations: For manual control, you can specify which dimension levels to aggregate. This is where you define the "fact table" rows that will be stored.
    • Select Aggregation Names: Assign meaningful names to your aggregation designs.
    • Choose Aggregation Storage: Decide whether to use a unified (single large aggregation table) or distributed (multiple smaller tables) approach.
  5. Deploy your project to update the cube with the new aggregation design.

Aggregation Granularity and Performance Trade-offs

Creating too many aggregations can lead to a significant increase in cube size and processing time. Conversely, not creating enough aggregations will result in poor query performance. The key is to find a balance.

Key Considerations:

SSAS provides tools to estimate the impact of aggregation designs on cube size and query performance. Use these tools to make informed decisions.

Aggregation Roles

When you create an aggregation design, SSAS categorizes the aggregations:

Managing Aggregation Designs

After creating an aggregation design, it needs to be processed along with the cube. During cube processing, SSAS builds and stores the data defined in the aggregation design.

Performance Tuning:

You can use the Aggregation Usage wizard in SSDT to analyze existing usage patterns and generate recommended aggregation designs. This wizard can help you identify which aggregations are being used and suggest new ones to improve performance.

Example Scenario

Consider a sales cube with a 'Date' dimension (Year, Quarter, Month, Day) and a 'Product' dimension (Category, Subcategory, Product). A common query might ask for total sales by 'Category' and 'Year'.

Without an aggregation design, SSAS would have to aggregate all individual product sales for each year. With an aggregation design, you could pre-calculate and store the total sales for each 'Category' and 'Year' combination. This would make queries for this specific combination extremely fast.

Aggregation Design Name Cube Measures Dimension Usage Estimated Size
Agg_Sales_Year_Category SalesCube [Measures].[InternetSalesAmount] Date (Year), Product (Category) 100 MB
Agg_Sales_All_Levels SalesCube [Measures].[InternetSalesAmount] All Dimensions (Highest Levels) 500 MB