You are on page 1of 14

Dynamics AX Performance

Optimization Guide

By Martin Zhen & Daniel Liao

Much of the information presented in this book is based on findings from realworld customer deployments. and discover that Dynamics AX 2012 includes a few new features. While you may notice some minor changes between the two versions. the descriptions are intended as brief highlights to aid understanding. or develop Dynamics AX. We cannot guarantee the accuracy of any information presented. It outlines guidelines for improving the performance of Dynamics AX running on Microsoft SQL Server.PREFACE This book is a practical guide for database administrators and Dynamics AX technical consultants who implement. every example in this book will work with Dynamics AX 2009 and everything you learn here is applicable to both Dynamics AX 2012 and Dynamics AX 2009. WHICH VERSION OF DYNAMICS AX IS COVERED IN THIS BOOK? All the examples in this book are based on Dynamics AX 2012. express or implied. maintain. rather than as thorough coverage. most of what is covered in this book also applies to Dynamics AX 2009. This book and its content are provided as is without warranty of any kind. Also. and should not be interpreted as an offer or commitment. In fact. in this book. . We make no warranties.

Zhen@outsourceax. please contact us via emails to Martin. such as a spelling mistake or a faulty piece of code. To find the errata page for this book.outsourceax.com or Daniel@outsourceax. If you find an error in our book. no one is perfect. and mistakes do occur.com . . However.com/AXPerfBook and click the Errata link. and at the same time. By sending in errata. we would be very grateful for your feedback. you may save other readers’ hours of frustration.AVAILABLE SUPPORT We make every effort to ensure that there are no errors in the text. If you have any comments regarding the book. go to http://www. you will be helping us provide even higher quality information.

0. 3. .ABOUT THE AUTHORS Martin Zhen started as a Dynamics AX developer in 2004. He started as a developer on Microsoft Dynamics AX in 2004 primarily working on a Chinese localization project with Dynamics AX 3. a Chinese offshore development company in Shanghai.com). He has worked on many projects based on AX versions 2. helping them to identify and rectify SQL Server-related issues for Dynamics AX applications. He currently works as a principle technical consultant at OutsourceAX Development (outsourceax.0. proactive consulting assistance for Dynamics AX environments. specializing in problem resolution support. and 2012. 4. 2009. He has worked on Dynamics AX environments for leading corporations in various business domains.5.0 for Microsoft. Daniel Liao runs OutsourceAX Development. China.

...........................................3 Instant File Initialization .............................4...............................................................1 SQLIO – Disk Performance Test Tool ................................................................................1 Using SQL Server Profiler ......................................... 31 2. 33 2.................. 53 2................... 9 1..................................................... 60 2...................................................................2.4.............................................................................................................1.................................4..........................3......................................... 80 ................ 18 2 MONITORING HARDWARE...............................3.....3 DATABASE I/O ........................................ 52 2..................2...............................................................................1 HARDWARE MONITORING .................................................2... 17 1.....................................................................3..................................1 Pessimistic Concurrency Control ..................................... 23 2........................2 HOW DYNAMICS AX MANAGE SESSIONS.......................................................................... 51 2....................................................................................................1 Server/Client Session ............................... 33 2..............................1.........4......................................3..4 MONITORING DYNAMICS AX ......5 Selected DBCC Commands ..........2.........................2 Using Dynamic Management Views . 65 2.......... 17 1.................................1... 50 2........2 SQLIOSim – Disk Stress Test Tool ......... 4 1 UNDERSTANDING DYNAMICS AX ..................... AND FILEGROUPS ..4.................................................. 12 1.3.......1 Dynamics AX Trace Parser ...............................4 Microsoft Visual Studio Profiling Tools ...........PREFACE ...................... 78 3.............2........................................ 49 2... 80 3..3.............................4.. 51 2......................4.3....................................................................................... DATABASE...............................................................................................................................................................3....................... 9 1........... 79 3............ 2 AVAILABLE SUPPORT ........................................... 23 2................................................. 17 1..................................................2 Microsoft Dynamics AX Performance Counters...................................................3 Finding Current Users and Processes ................... 51 2............. 28 2..............2 Optimistic Concurrency Control .........4............................1.....................................................................1 DYNAMICS AX ARCHITECTURE ........... 71 2................ 49 2........................... 53 2..........2.. 78 3. AND DYNAMICS AX ......5 PerformanceTester .........................................................................................................1 Dynamics AX and its Components ...................................................................................................4 Long I/O Requests ............1 Using System Monitor ................................................................... 3 ABOUT THE AUTHORS................................................2 Windows Event Tracing .................... 12 1.........................4 Decoding the Object Blocking a Process ...................3 CONCURRENCY CONTROL WITHIN DYNAMICS AX ..................8 Process Monitor ................................................. 75 2....3 WCF Performance Counters with Dynamics AX 2012 AOS .................................... 68 2...6 Performance Testing for Enterprise Portal (Web Performance Test) ............1...............3 How To Set Up Concurrency Model Globally ......................................2 FILES.........................2 DATABASE MONITORING .....1...............4 Implementing Optimistic Concurrency Control ....................................................................... 77 3 SETUP AND CONFIGURATION ......................................1 INPUT/OUTPUT (I/O) CONFIGURATION ....... 17 1...2 Typical I/O Performance Recommended Range...7 Performance Analyzer for Microsoft Dynamics AX (DynamicsPerf) .............................3 WCF Service Trace Viewer Tool .......... 9 1...............................1 Redundant Array of Independent Disks (RAID) Configuration ........................3 TEMPDB PLACEMENT AND TUNING ........................ 23 2........WebServer Performance Tester .......................................................................................................................... 44 2.............................................. 78 3............................................... 70 2............... 51 2.....................................................

......................... 92 3..................................7 ANTIVIRUS SOFTWARE ............................109 4......................................................118 .............................2 Asynchronous Statistics Update ................................................................................................................2 HIGH PROCESSOR UTILIZATION ................6..........................................105 4.....................................3 AOS Authorization .......................................................................................6............................................................ 83 3....................................................................... 98 3................................ 94 3.........4 Important SP_Configure Parameters ........................................3 Parameterization................................................................................................................ 82 3...................................................................2 Full Recovery Model ...............111 4..................................................................... 88 3................................103 4 COMMON DYNAMICS AX PERFORMANCE PROBLEM ...............107 4.................................................................................1 Simple Recovery Model...............5 Auto Create Statistics .......1 Dealing with Bad Parameter Sniffing ......... 83 3............................................6........10 DYNAMICS AX SETUP ................................................................................ 88 3..........................2 Workflow Notifications......................4 DATA AND LOG FILE SIZING.................................................6 DATABASE OPTIONS .......7 EXTENSIVE LOGGING ....................................10......109 4............................112 4..............8..........................9....................................................................................................................................................8.................................... 82 3............................................................................................................................9.......8 SQL SERVER WAIT TYPES .....3 Bulk-Logged Recovery Model...............................................1 CXPACKET .................3 DISK I/O BOTTLENECKS ..................8................... 98 3............................................................................................... 89 3....................................................................1.................5............................10...............................8................6 Advanced Performance Option .......................1 Statement Compilation ..........................................10.............105 4.1 Application Integration Framework .......................................................4 Use AppFabric for NLB topology .............................................110 4........3 Memory Tuning ........5 RECOVERY MODELS ......4 Auto Update Statistics ..............................102 3............................................................................. 99 3.......... 88 3.............................112 4........1 Installation Considerations ............................................................................................................................................... 87 3...............................9 PARAMETER SNIFFING .10.........................116 5 OPTIMIZING DYNAMICS AX SQL STATEMENT..9 NETWORK CAPACITY ...11 OFFLOAD REPORTING (SSRS) ........................................ 86 3......................................113 4.............104 4...................6.................4 MEMORY BOTTLENECKS ........ 98 3...............................................1 Increase buffer size .......................................1...........................6 BLOCKING AND DEADLOCKING ISSUES ........................ 84 3.....5........5 Network Protocols and Pagefile.....................8..............................5........................................................................................................................1 Read Committed Snapshot Isolation (RCSI) ............................3.... 89 3.....3 Configuring HTTP Compression in IIS ....108 4. 87 3..........2 Cache of Number Sequences .................9............................................8....................................................2 Hyper-Threading...................6............................8 SQL SERVER CONFIGURATIONS ...........104 4....2 Turn Off Parameter Sniffing .............110 4..................................114 4...............................................5 HIGH MEMORY USAGE WHEN RUN IN IL(BATCH MODE) ....113 4...........................................2 Set Based Operations.....................................................................................1...8.......................................................7................................ 82 3................... 99 3.. 83 3.......................................................8.............................. 85 3..............8.........................................................................................................................................................................................1 LARGE NUMBER OF ROUNDTRIPS TO THE DATABASE .....3 ASYNC_NETWORK_IO ......................................................... 98 3.....104 4............................................................................7......................104 4..................................................... 95 3..............1 TCP Chimney ................2 PAGEIOLATCH_EX .....109 4.......................................................

..................1 Use Set Based Operations.................... 127 5......................................................... 155 7 DATABASE MAINTENANCE ...3 Extended Events ....5.......................3 Default Maximum Number of Rows Returned ..............6 TRACE FLAGS ............... 139 6..... 128 5.2 Maximum Buffer Size .......................................................................................................................................................... 138 6..................................... 138 6.....................................4 PERFORMANCE MONITORING AND DATA COLLECTION ..................................5 Use table caching ...............................................................................2 DYNAMICS AX DEVELOPMENT BEST PRACTICE FOR PERFORMANCE .........5..........................................2..............................4.5............................. 144 6.................................4................3 Avoid Using Pessimisticlock in X++ ..........................4 Select wisely .................................. 159 7............................1 Data Collector and Management Data Warehouse ..........2..............................5 USING HINTS .......... 120 5........................................................................................................................3 ODBC API Server Cursor Performance Enhancements ...........1 QUERYING SQL SERVER............2 Implementing Trace Flags ......... 153 6................................... 153 6.............................. 132 5.............. 135 5..............2... 160 7..............................1 Hot Add CPU..................... 121 5.......3 SQL PRE-PROCESSING IN MICROSOFT DYNAMICS AX ...6............................1 Index Hints ....................................................4.......6...................................2 Use the SysGlobalCache /SysGlobalObjectCache Class .........................................6.................. 154 6...................................... 121 5................ 120 5............................. 120 5............................................3 REDUCING FRAGMENTATION ...........................................................................................2 Memory Monitoring DMVs...................... 129 5.........................2............................4................................... 138 6.....................................................2 BACKUP AND STORAGE OPTIMIZATION ....4....................................................1 Transparent Data Encryption (TDE) .....................2 SQL Server Audit ........... 120 5..4........................................................1 RESOURCE MANAGEMENT ........... 144 6........................... 128 5.....5....1 Controlling Trace Flags ................................................................. 154 6............................. 121 5........ 120 5..................2 NUMA ..6........................................2.........2.... 123 5.................................................................................................. 156 7.............................1 Resource Governor ............................. 150 6......................................................3........................................................................................2................4 STATEMENT CACHE & MAXIMUM BUFFER SIZE .........1 MANAGING INDEXES .............................................................................6 Use Display/Edit Method Caching Where Appropriate ................................................... 125 5.............2 DETECTING FRAGMENTATION ...................................... 154 6....................................................................................................................1 Backup Compression . 148 6.....................................................................................................5.....4 Trace Flags Recommended for use with Dynamics AX ...............................................1...3............................. 156 7........................................1 Statement Cache (Open cursors) .........................................1 Index-Related Dynamic Management Views ...............................3 Monitoring Trace Flags..........................4 Statement with ForceLiterals Keyword . 132 5...................................................................... 151 6.6..................................................2.................................................... 132 5.....5...........................................2 Plan Guides ....................................1.................... 123 5.................................. 140 6..... 162 ..............................6.. 124 5.5 QUERY PERFORMANCE OPTIMIZATION .............................. 148 6...................... 119 5..........................................................6 HARDWARE OPTIMIZATIONS ................................................................................. 129 5.................................. 135 6 SQL SERVER PERFORMANCE AND COMPLIANCE OPTIMIZATIONS FOR DYNAMICS AX ......................2 Data Compression ................................................ 146 6......................................... 139 6.....................................................1 Plan Freezing .................................................................................................................................................................4..................................................2 Lock Escalation ..............4 STATISTICS .............................3 AUDITING AND COMPLIANCE ..................................... 156 7..................................

...............................................................................................5.............................4................3................................................3 Web Server hosting Enterprise Portal ............4 Batch Servers ..........................................................................................167 7.......3 Sizing Guidance for Each Components (AX 2009) .......................................188 8.............162 7........................................................................................................188 8.........................................................1 HARDWARE SIZING .....5 Viewing Statistics .189 8....................................................................................................................................5.4.......................181 8............................4........................................................................4........5........................3 Lock Escalations ...4..................................................175 8.......166 7..................6 Optimize SCSI and Disk Performance ...2 Hyper-V Virtualization .........1.....................................179 8............................177 8...................................................3 DYNAMICS AX SERVER VIRTUALIZATION ....194 INDEX ........3.........................179 8..................1............4.4........6 DEDICATED ADMINISTRATOR CONNECTION (DAC)...............................................................................................................................165 7........1.........2....3.................................189 8.........................................178 8....................175 8........................178 8.............2 SIZING METHODOLOGY ................................................4 Lock Escalation Trace Flags .....174 8 INFRASTRUCTURE & HYPER-V VIRTUALIZATION ...........................................................................................................................................1...........................................................................................5 Minimize Operating System Overhead..................................................5 CONTROLLING LOCKING BEHAVIOR ..........190 APPENDIX ..........................................................................186 8...195 ...................................................................163 7.4 HYPER-V BEST PRACTICES .........3 Implement Hyper-V Integration Services .164 7.......................5................186 8........177 8.............4 Updating Statistics........................175 8................5 Deadlocks .170 7.......................3 User-Created Statistics.................5........................................1 Isolation Levels .........................................................................................2..........................................4.............................1.............................................2 Application Server hosting AOS .....................................................4..............3 Hardware Considerations ...............................................................................184 8...................................................4.................186 8..2 Disabling AUTO_UPDATE_STATISTICS at the Table Level ...................................................................................169 7...........1 Work Load .........................................4..........................................190 8..................................................191 BIBLIOGRAPHY ..187 8........................................................2 Lock Granularity ......7.....1 DO NOT virtualize SQL Server.................4 Maximize Memory Usage ................................................1 AUTO_CREATE_STATISTICS and AUTO_UPDATE_STATISTICS ...............190 8......................................2 Sizing Guidance for Each Components (AX 2012) ..............166 7..............................176 8........................................................6 Firewall..............................5 Remote Desktop Session Host Server (RDSH Server) .........1 Virtualization Benefits ........................................2........................................1..............2 Increase Network Capacity ....168 7.......164 7.....................................................................................................................................................................1 Database Server ..................

Collect and view real-time performance data in the form of counters. SQL Server AOS SQLdiag utility The SQLdiag utility is a general purpose diagnostics collection utility that can be run as a console application or as a service. and for many Microsoft SQL Server resources such as locks and transactions. and use it to monitor your servers over time or troubleshoot specific problems with your servers. You can use SQLdiag to collect logs and data files from SQL Server and other types of servers. SQL Server . Used for SQL Server Performance Monitor Use Performance Monitor to monitor the utilization of system resources. for server resources such as processor and memory use.Appendix Analysis Tools for Troubleshooting Performance Tools SQL Server Profile Trace Description Microsoft SQL Server Profiler is a graphical user interface to SQL Trace for monitoring an instance of the Database Engine.

It combines the features of two legacy Sysinternals utilities. simultaneous logging to a file. full thread stacks with integrated symbol support for each operation. to provide an integrated view of application performance at run time. Filemon and Regmon. and adds an extensive list of enhancements including rich and non-destructive filtering. comprehensive event properties such session IDs and user names. Process Monitor is an advanced monitoring tool for Windows that shows real-time file system. such as remote procedure calls (RPCs) and Microsoft SQL Server. Network Monitor is a protocol analyzer that allows the capture of network traffic and the ability to view and analyze it. reliable process information. Trace Parser consolidates information from multiple sources. SQL Server EP AOS SQL Server EP AOS X++ CIL . and much more.Performance Analyzer for Microsoft Dynamics Process Monitor Network Monitor Trace Parser Performance Analyzer for Microsoft Dynamics is a set of scripts to collect and analyze performance information from the database and application tiers of Microsoft Dynamics products. Registry and process/thread activity.

2009 SP1 2009 SP1 HF (Build# 5. 4. and target performance-related issues in their code. CIL Cursor Types in Dynamics AX Version 3.Visual Studio Profiling Tools The Visual Studio Profiling Tools let developers measure. These tools are fully integrated into the IDE to provide a seamless and approachable user experience. evaluate.1500.0 SP1.0 SP6 4.0. 2012 R2 Cursor FFO for read-only Dynamic for pessimistic locking FFO for read-only FFO for optimistic locking Dynamic for pessimistic locking FFO for read-only FFO for optimistic locking Dynamic for pessimistic locking FFO for read-only FFO for optimistic locking FFO for pessimistic locking FFO for read-only FFO for optimistic locking FFO for pessimistic locking Dynamic for full-text search Repeatable Read Support No RCSI Suppor t No Yes Yes Yes Yes Yes Yes Yes Yes .0 SP2 2009.3775) 2012 R1.

B. Microsoft Press (2009) Luis X.com/b/axsupport/) Dynamics AX in the Field Blog (http://blogs.au) Dilip's blog on DYNAMICS AX (http://daxdilip.com) . Inside Microsoft Dynamics AX 2012.aspx) AX Support Blog (http://blogs.com/b/mfp) Brandon George's Microsoft Dynamics AX Blog (http://dynamics-ax.msdn. Inside Microsoft Dynamics AX 2009.microsoft.blogspot.msdn. Apress (2006) Other Sources Microsoft Dynamics AX Developer Center (http://msdn.com) Palle Agermarks Microsoft Dynamics AX blog (http://palleagermark.blogspot. Microsoft Press (2012) Lars Dragheim Olsen/Michael Fruergaard Pontoppidan/Hans Jorgen Skovgaard/Tom Kaminski/Deepak Kumar/Satish Thomas.blogspot.microsoft.com/b/axinthefield) MFP's Two Cents Blog (http://blogs.Bibliography Literature The Microsoft Dynamics AX Team.msdn. Mourão/ David Weiner.com. Dynamics AX: A Guide to Microsoft Axapta.com/en-us/library/dd362025.com/en-us/dynamics/ax/) Microsoft TechNet Library – Dynamics AX (http://technet.

103.30.126 Full Recovery 82 High Processor Utilization 91.125.186 Hyper-Threading 88.139 Batch Server 176.109 AOS Authorization 105 Application Object Server (AOS) 8.83.29.152.177 Lightweight pooling 91 Lock Escalation 153.43.181.131.177 Buffer size 103.135 Dedicated Administrator Connection (DAC) 173 Display/Edit Method Caching 120 DMV 110.125 Max degree of parallelism 91.50.131.124.176.37 SQL Server Reporting Service (SSRS) 102.188 Non-Uniform Memory Access (NUMA) 154 ODBC API Server Cursor 128.config file 108 Address Windowing Extensions (AWE) 88.134 DBCC SQLPERF 46 Deadlock 33.28.14 Set Based Operations 104.176 I/O requests 50.79 Page Compression 140 PerformanceTester 70 PessimisticLock 18.133 DBCC TRACEON 49.36.114.160 FIRSTFAST 118.149 Dual Core 79.45.120.87 Auto Update Statistics 86 Ax32serv.92.168 Locking 83.exe.165 Execution Plan 36.89 Backup Compression 138.163.79 I/O consumer 44 Implicit Cursor Conversion 129 Index 36.146 SQL Server Profiler 32.135 FFO 128.112.104 DBCC CACHESTATS 49 DBCC DBREINDEX 160 DBCC TRACEOFF 49.111 Maximum buffer size 123.121.Index -internal=nocursorreuse 117 -internal=comments 117 Application Integration Framework (AIF) 10.184 Sizing Methodology 179 SQL Server Audit 145.127 Firewall 177 ForceLiterals 113.100.103 Database trip 103.127 Pessimistic concurrency control 17 Physical Address Extension (/PAE) 89 Plan freezing 153 Plan guide 129 Process Monitor 77 Processor Affinity 81 Quad Core 183.13 .129 Enterprise Portal 9.155 Index hint 127 Instant File Initialization 50.122 Bulk-Logged Recovery 82 Concurrency Control 16.127 Named Pipes 94 Network Interface Controller (NIC) 186.185.183 Statement cache 122.51 Keyset-driven cursor 129 Latency 78.74.17 PAGEIOLATCH_EX 111 Parallelism 92.172 Fast Forward Cursor 32.150 Exclusive Lock 17.82.98. 119 Asynchronous Statistics Update 84 Auto Create Statistics 86.167.182.154.147.105.178.126.124.191 Fibre Channel 186 FileGroups 79.70.92.126 SysClientSessions 11.140 Database 30.17 CPU 23.120 Shared Memory 95 ShowPlan XML 34 Simple Recovery 82 Sizing guidance 181.44 Cursor 39 CXPACKET 111 Data Compression 139.84.80 Dynamic Cursor 128.105 Parameterization 85 Performance Analyzer for Microsoft Dynamics 75 Performance Monitor 28.184 Event Tracing for Windows (ETW) 52.10.125 Pessimistic locking 125.129.51.134 DBCC TRACESTATUS 49.130 OnlyFetchActive 119 OptimisticLock 17 Optimistic concurrency control 16.12.133.11.161.104 Hot Add CPU 153 Hyper-V 174.129.184 Read Committed Snapshot Isolation (RCSI) 84 RDSH Server 178 Remote Desktop Session Host Server 178 Resource Governor 138 Row Compression 141 Sales Order transaction lines per hour (SOTPH) 179 SCSI 190 Sessions 12.

53 143 24.168 135.SysGlobalCache SysGlobalObjectCache SysServerSessions Table caching TCP Chimney TCP/IP TempDB Thread Throughput Trace flag 1204 1211 1224 1244 4136 4199 120 120 10.169.170 153.79 186 17.187 131 135.135 Trace Parser Transparent Data Encryption (TDE) Transaction log Two Node Configuration Update conflict exception UpdLock Virtual hard disks (VHDs) Virtual machines (VMs) Virtualization Visual Studio Profiling Tools WCF Performance Counters WCF Service Trace Viewer Windows Performance Monitor 52.20 125 188 185 185.187 67.134.179 107.50.168 135 135 131.31 64 31.55.11.59 .84 177.68 30.186.178.153.12 121 98 95 81.