Adam Jorgensen Pragmatic Works Performance Optimization in SQL Server Analysis Services 2008 Agenda • • • • SSAS Query Processing Architecture Enhancing Query Performance Improving Processing Performance Tuning Server Resources Query Processing Architecture Client Application MDX Query • Session Management • Query Processing • Data Retrieval Session Management XML/A Listener Session Manager Security Manager Query Processor Query Processor Cache Storage Engine Storage Engine Cache Query Processing Data Retrieval Dimension Data Measure Group Data Attribute Store Fact Data Hierarchy Store Aggregations Job Architecture Request • CoordinatorExecutionMode • Negative means max number of jobs per core • Zero means no limit • Positive means number of jobs per server • Default is -4 • Works in tandem with MAXTHREADS and MAXPARALLEL Thread Coordinator Job … Job 1 Thread Job 2 Job N Thread Thread Query Processor • Executes MDX Queries and returns cell and row sets. • Builds an execution Plan to translate request into one or more SubCube requests. • Uses the Query Processor Cache to store the results for reusability Query Processor Cache • 3 Contexts • Cache Rules – Calculations created at query time – Context is chose by scope – Try for maximum re-use in the Global Cache • Partial Expressions are not Cached Query Context Session Context Global Context Data Retrieval Coordinator Job First Segment Job Second Segment Job Thread Thread Creates SubCube Request Storage Engine Cache (Y/N) … Last Segment Job Thread Aggregation (Y/N) Fact Table/Partition Agenda • • • • SSAS Query Processing Architecture Enhancing Query Performance Improving Processing Performance Tuning Server Resources Enhancing Query Performance Base lining Query Speed Cache Warming Diagnosing The Problem Optimizing MDX Optimizing Dimensions Using Partitions Maximizing Aggregations Usage Based Optimization Base Lining Query Speed • Trace Info – 0 – attribute is not included in query – * - ever member was requested – + - two or more members were requested – <integer value> - a single member of the attribute was hit Clear Cache Trace Query Warm Cache Trace Again Compare Diagnosing the Problem • Storage Engine – Long running sub-cube events • Optimize dimension design • Design aggregations • Use partitions • Query Processor • See delay in other steps (query processing) • Optimize MDX • Look for redundant queries Demo • Using SSAS and Profiler • Get the query Excel is running Identify Attribute Relationships • Default relations to Key • Base for Indexes • Cross products don’t need to go through key • Aggregations built on attributes can be used for related attributes • Flexible vs. Rigid Implementing Effective User Hierarchies • Attribute vs. User Hierarchies – Aggregation Usage Property • Natural vs. Unnatural Hierarchies Demo • Attribute Relationships and Hierachies Using Partitions • Advantages – Partition Slicing – Aggregation Design • Tips for Using Partitions – Slide Aggregations along partition hierarchy • i.e. – Last 7 days, Last 30 Days, 90, 6 months, etc.. – Indexes or slices will not be defines for partitions with fewer rows (4096 default) • Sizing • Increasing processing speed and flexibility • Increase manageability of bringing in new data • Support multiple aggregation designs Demo • Implementing Partitions Maximizing Aggregation Value Building, Suggesting, Influencing Aggregations Interpreting Aggregations Detecting Aggregation Hits Demo • Aggregations and Usage Based Optimization Agenda • • • • SSAS Query Processing Architecture Enhancing Query Performance Improving Processing Performance Tuning Server Resources Processing Job Overview • Parent – Child Jobs • Best Opportunity to Increase Performance and Scale Measure Group Partition Fact Table & Aggregations Parent Processing Job Parent Partition/ Child Processing Child Fact Data Child Aggregation Parent Partition/ Child Processing Child Fact Data Where Are You Spending Your Time? • Partition or Dimension Processing ? • ProcessFull vs. ProcessData and ProcessIndex • During ProcessData – MSOLAP:Processing – Rows read/Sec >0 • During ProcessIndex – MSOLAP:Proc Aggregations – Row created/Sec > 0 Dimension Processing Best Practices • Use SQL Views to Implement Query Binding • Optimize Attribute Processing Across Multiple Sources • Reduce Unnecessary Attributes • Adjust/Remove Bitmap Indexes • Tune Relational Processing Query Partition Processing Architecture • Processes Using Jobs • Three Concurrent Threads – Send SQL to extract source data – LookUp Dimension Keys and populate processing buffer – Write Buffer to disk when it fills • Aggregations and Bitmap Indexes – May also overflow to disk – created in memory during processing Process Fact Data Build Aggregations Build Bitmap Indexes Partition Processing Best Practices • Inserts – ProcessFull vs. ProcessAdd – Rotating Partitions • Updates – ProcessFull – Journaling to only implement Inserts • (See Insert Techniques) • Deletes – Partitioning – ProcessUpdate – Remove Data From Table and ProcessFull (longer) • Pick Efficient Data Types Tuning the Relational Query • Minimal Joins in Source Queries • Partitioning Alignment – Each SSAS partition should only hit 1 Relational Partition – More than 1 cube partition can hit 1 relational partition • Clustered Indexes – Especially without 1:1 partition relationship • Keep FillFactor VERY high • Data Compression – Reduce IO • Reduce Locking when possible Tuning ProcessIndex Phase • Avoid Spilling Data to Disk Partition Process Job – MSOLAP:Proc Aggregations\Temp file bytes written/sec • Eliminate IO bottleneck • Increase Partitions for Parallelism Segments Segments Segments Thread n Thread 1 – Increase means faster aggregation processing Thread 0 • MSOLAP:Proc Aggregations – Row created/sec n = CoordinatorBuilMaxThread Agenda • • • • SSAS Query Processing Architecture Enhancing Query Performance Improving Processing Performance Tuning Server Resources Tuning Server Resources • PreAllocate Physical Ram for SSAS – Hard reservation – otherwise memory will be released when not under load • Using Large Pages – Lock Pages in Memory – Cannot be swapped to page file • Need to watch Carefully • Leave 20% for the OS • Disable Flight Recorder Questions and Where to Find Adam