Home
%3CLINGO-SUB%20id%3D%22lingo-sub-782815%22%20slang%3D%22en-US%22%3EAzure%20Database%20for%20MySQL%20Performance%20Troubleshooting%20Basics%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-782815%22%20slang%3D%22en-US%22%3E%3CP%3EIf%20you%20are%20facing%20Performance%20problems%20with%20Azure%20Database%20for%20MySQL%2C%20these%20can%20often%20be%20resolved%20by%20doing%20basic%20troubleshooting%20steps%20to%20understand%20the%20cause%20of%20the%20bottleneck%20and%20then%20explore%20the%20options%20to%20fix%20it.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22text-align%3A%20center%3B%22%3E%3CFONT%20size%3D%225%22%3E%3CSTRONG%3EServer%20Level%20Troubleshooting%3C%2FSTRONG%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%20style%3D%22text-align%3A%20left%3B%22%3E1-%20%3CSTRONG%3EResource%20Utilization%3C%2FSTRONG%3E%3A%20It's%20very%20important%20to%20start%20by%20making%20sure%20that%20you%20are%20not%20maxing%20out%20any%20of%20your%20resource%20limits%2C%20reaching%20high%20levels%20of%20resource%20utilization%20will%20cause%20a%20performance%20issue%20this%20can%3C%2FP%3E%0A%3CP%20style%3D%22text-align%3A%20left%3B%22%3E%26nbsp%3Bbe%20avoided%20by%20monitoring%20server's%20resource%20utilization%20on%20the%20Azure%20Portal.%3C%2FP%3E%0A%3CP%20style%3D%22text-align%3A%20left%3B%22%3EIn%20Azure%20Database%20for%20MySQL%20resource%20limits%20determined%20by%20the%20service%20tier%20that%20you%20are%20using%20and%20the%20number%20of%20vCores%20and%20Storage%20size%20that%20you%20provision%20all%20this%20information%20is%20documented%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fmysql%2Fconcepts-pricing-tiers%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehere%3C%2FA%3Eand%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fmysql%2Fconcepts-limits%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehere%3C%2FA%3E%2C%20you%20can%20navigate%20to%20your%20Azure%20Database%20for%20MySQL%20and%20use%20the%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fmysql%2Fconcepts-monitoring%23metrics%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EMetrics%3C%2FA%3Eblade%20to%20check%20if%20you%20are%20maxing%20out%20any%20of%20your%20resource%20limits.%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F128256iA4578DD641DEF35A%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22mysql%20metrics.jpg%22%20title%3D%22mysql%20metrics.jpg%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3E2-%20Consider%20ANALYZE%20and%20OPTIMIZE%20all%20database%20tables%20frequently%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EAnalyze%3C%2FSTRONG%3E%3A%20Performs%20a%20key%20distribution%20analysis%20and%20stores%20the%20distribution%20for%20the%20named%20table%20or%20tables%2C%20clears%20table%20statistics%20from%20the%20%22INFORMATION_SCHEMA.INNODB_TABLESTATS%22%20table%20and%20sets%20the%20%22STATS_INITIALIZED%22%20column%20to%20Uninitialized.%20Statistics%20are%20collected%20again%20the%20next%20time%20the%20table%20is%20accessed%2C%20this%20will%20help%20pushing%20a%20better%20execution%20plans%20for%20your%20queries%20if%20the%20data%20in%20the%20table%20was%20modified%20recently.reference%3A%26nbsp%3BANALYZE%20TABLE%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EOptimize%3C%2FSTRONG%3E%3A%26nbsp%3B%3CSPAN%3EOnce%20your%20data%20reaches%20a%20stable%20size%2C%20or%20a%20growing%20table%20has%20increased%20by%20tens%20or%20some%20hundreds%20of%20megabytes%2C%20consider%20using%20the%26nbsp%3BOPTIMIZE%20TABLE%20statement%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3Bto%20reorganize%20the%20table%20and%20compact%20any%20wasted%20space.%20The%20reorganized%20tables%20require%20less%20disk%20I%2FO%20to%20perform%20full%20table%20scans.%20This%20is%20a%20straightforward%20technique%20that%20can%20improve%20performance%20when%20other%20techniques%20such%20as%20improving%20index%20usage%20or%20tuning%20application%20code%20are%20not%20practical.In%20short%20this%20will%26nbsp%3Breorganizes%20the%20physical%20storage%20of%20table%20data%20and%20associated%20index%20data%2C%20to%20reduce%20storage%20space%20and%20improve%20I%2FO%20efficiency%20when%20accessing%20the%20table.%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3Ereference%3A%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fdev.mysql.com%2Fdoc%2Frefman%2F5.7%2Fen%2Foptimizing-innodb-storage-layout.html%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EOptimizing%20Storage%20Layout%20for%20InnoDB%20Tables%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3E3-%20Make%20sure%20you%20are%20applying%20Application%20side%20best%20practices%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%20style%3D%22padding-left%3A%2030px%3B%22%3E%3CFONT%20size%3D%222%22%3E%3CFONT%20size%3D%223%22%3E%3CSTRONG%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.azure.cn%2Fen-us%2Fmysql-database-on-azure%2Fmysql-database-connection-pool%23-%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ea)%20Connection%20pooling%3C%2FA%3E%3A%3C%2FSTRONG%3E%3CSPAN%3EThis%20significantly%20reduces%20connection%20latency%20by%20reusing%20existing%20connections%20and%20enables%20higher%20database%20throughput%20(transactions%20per%20second)%20on%20the%20server.%3C%2FSPAN%3E%3C%2FFONT%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%20style%3D%22padding-left%3A%2030px%3B%22%3E%3CFONT%20size%3D%223%22%3E%3CSTRONG%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fvirtual-network%2Fcreate-vm-accelerated-networking-cli%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Eb)%20Accelerated%20Networking%3A%26nbsp%3B%3C%2FA%3E%3C%2FSTRONG%3E%3CSPAN%3Eenables%20single%20root%20I%2FO%20virtualization%20(SR-IOV)%20to%20a%20VM%2C%20greatly%20improving%20its%20networking%20performance.%20This%20high-performance%20path%20bypasses%20the%20host%20from%20the%20datapath%2C%20reducing%20latency%2C%20jitter%2C%20and%20CPU%20utilization%2C%20for%20use%20with%20the%20most%20demanding%20network%20workloads%20on%20supported%20VM%20types.%3C%2FSPAN%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%20style%3D%22padding-left%3A%2030px%3B%22%3E%3CFONT%20size%3D%222%22%3E%3CSPAN%3E%3CSTRONG%3Ec)%20Application%20and%20Database%20should%20be%20in%20the%20same%20Data%20Center.%3C%2FSTRONG%3E%3C%2FSPAN%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%20style%3D%22padding-left%3A%2030px%3B%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3E4-%20Tune%20server%20parameters%20to%20better%20serve%20your%20application%20workload%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3EAzure%20Database%20for%20MySQL%20allows%20you%20to%20configure%20server%20parameters%20for%20the%20values%20that%20better%20serve%20your%20workload%2C%20check%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fmysql%2Fhowto-server-parameters%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ethis%20documentation%3C%2FA%3Eto%20learn%20how.%20Each%20application%20has%20best%20practices%20for%20those%20parameter%2C%20please%20review%20those%20in%20order%20to%20get%20the%20best%20out%20of%20the%20database%20server.%20Some%20of%20the%20parameters%20that%20you%20might%20need%20to%20check%20is%3A%3C%2FP%3E%0A%3CP%20style%3D%22padding-left%3A%2030px%3B%22%3E%3CSTRONG%3Ea-%26nbsp%3Binnodb_buffer_pool_size%3A%3C%2FSTRONG%3E%3CBR%20%2F%3E%3CFONT%20size%3D%223%22%3E%3CSPAN%3EThe%20buffer%20pool%20is%20where%20data%20and%20indexes%20are%20cached%3A%20having%20it%20as%20large%20as%20possible%20will%20ensure%20you%20use%20memory%20and%20not%20disks%20for%20most%20read%20operations.%3C%2FSPAN%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%20style%3D%22padding-left%3A%2030px%3B%22%3E%3CFONT%20size%3D%223%22%3E%3CSTRONG%3Eb-%26nbsp%3Binnodb_file_per_table%3A%26nbsp%3B%3C%2FSTRONG%3E%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20size%3D%223%22%3EBy%20default%2C%20InnoDB%20tables%20are%20stored%20in%20the%20system%20tablespace.%20As%20an%20alternative%2C%20you%20can%20store%20each%20InnoDB%20table%20in%20its%20own%20data%20file.%20This%20feature%20is%20called%20%E2%80%9Cfile-per-table%20tablespaces%E2%80%9D%20because%20each%20table%20has%20its%20own%20tablespace%20data%20file%20(.ibd%20file).%20learn%20more%20about%20it's%20advantages%20here.%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%20style%3D%22padding-left%3A%2030px%3B%22%3E%3CFONT%20size%3D%223%22%3E%3CSTRONG%3Ec-%26nbsp%3Bquery_cache_size%3C%2FSTRONG%3E%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20size%3D%223%22%3EThe%20amount%20of%20memory%20allocated%20for%20caching%20query%20results.%20by%20default%20this%20is%20turned%20OFF%2C%20read%20more%20about%20this%20here.%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%20style%3D%22padding-left%3A%2030px%3B%22%3Ed-%26nbsp%3Blog_binThe%20server%20logs%20all%20statements%20that%20change%20data%20to%20the%20binary%20log%2C%20which%20is%20used%20for%20replication%2C%20If%20you%20don't%20have%20replication%20enabled%20please%20make%20sure%20the%20you%20have%20this%20parameter%20turned%20OFF.%3C%2FP%3E%0A%3CP%20style%3D%22padding-left%3A%2030px%3B%22%3E%3CSTRONG%3Ee-%20query_store_capture_mode%3D%20NONE%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%20style%3D%22padding-left%3A%2030px%3B%22%3EQuery%20store%20capture%20can%20help%20you%20identify%20your%20top%20consumers%20and%20wit%20statistics%20but%20this%20also%20adds%20overhead%20in%20terms%20of%20performance%20as%20the%20background%20process%20will%20be%20be%20collecting%20data%20all%20the%20time.%3C%2FP%3E%0A%3CP%20style%3D%22padding-left%3A%2030px%3B%22%3E%3CSTRONG%3Ef-%20slow_query_log%3D%20OFF%3CBR%20%2F%3E%3C%2FSTRONG%3ETurning%20slow%20query%20log%20off%20will%20save%20data%20collection%20overhead%20which%20contributes%20to%20better%20performance%2C%20if%20you%20don't%20need%20low%20query%20log%20turn%20off%20and%20you%20can%20enable%20it%20later%20if%20needed.%3C%2FP%3E%0A%3CP%20style%3D%22padding-left%3A%2030px%3B%22%3E%3CSTRONG%3Eg-%26nbsp%3B%3CEM%20class%3D%22azc-grid-filterable-match%20fxs-highlight%22%3Elog%3C%2FEM%3E_queries_not_using_indexes%3D%20OFF%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%20style%3D%22padding-left%3A%2030px%3B%22%3EThis%20parameter%20helps%20you%20determine%20missing%20indexes%2C%20while%20its%20awesome%20to%20learn%20about%20missing%20indexes%20but%20keeping%20this%20parameter%20enabled%20all%20the%20time%20will%20drop%20query%20performance%20significantly%2C%26nbsp%3B%3CSPAN%3Erule%20of%20thumb%20here%20is%20to%20use%20it%20when%20you%20need%20it.%3C%2FSPAN%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22text-align%3A%20center%3B%22%3E%3CFONT%20size%3D%225%22%3E%3CSTRONG%3EQuery%20Level%20Troubleshooting%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FSTRONG%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%3CSTRONG%3EUse%20Microsoft%26nbsp%3BIntelligent%20Performance%20tools%20to%20explore%20queries%20that%20are%20considered%20top%20consumers%20and%20also%20learn%20about%20missing%20indexes%20along%20with%20recommendation%26nbsp%3Band%20full%20analysis%20for%20your%20workload.%20Intelligent%20Performance%20for%20Azure%20Database%20for%20MySQL%20includes%20(QPI%2C%20Performance%20Recommendations%2C%20Slow%20query%20log)%3A%3C%2FSTRONG%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%3CSTRONG%3E1-%20%3C%2FSTRONG%3E%3CSTRONG%3ELeverage%20Query%20Performance%26nbsp%3BInsight%20(QPI)%3CBR%20%2F%3E%3C%2FSTRONG%3EQuery%20Performance%20Insight%20helps%20you%20to%20quickly%20identify%20what%20your%20longest%20running%20queries%20are%2C%20how%20they%20change%20over%20time%2C%20and%20what%20waits%20are%20affecting%20them%2C%20this%20can%20help%20you%20determine%20problematic%26nbsp%3Bqueries.%20Tutorial%20on%20how%20to%20use%20QPI%20can%20be%20found%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fmysql%2Fconcepts-query-performance-insight%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehere%3C%2FA%3E.%26nbsp%3B%3CSTRONG%3E%3CBR%20%2F%3E%3C%2FSTRONG%3E%3CSTRONG%3E%3CBR%20%2F%3E%3C%2FSTRONG%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%3CSTRONG%3E2-%20Use%20Performance%20Recommendations%20feature%3C%2FSTRONG%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EThe%20Performance%20Recommendations%20feature%20analyzes%20your%20databases%20to%20create%20customized%20suggestions%20for%20improved%20performance.%20To%20produce%20the%20recommendations%2C%20the%20analysis%20looks%20at%20various%20database%20characteristics%20including%20schema.%20you%20can%20read%20more%20about%20this%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fmysql%2Fconcepts-performance-recommendations%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehere%3C%2FA%3E.%3C%2FP%3E%0A%3CP%3EPlease%20consider%20also%20to%20read%26nbsp%3B%3CBR%20%2F%3E%3CA%20id%3D%22link_9%22%20class%3D%22page-link%20lia-link-navigation%20lia-custom-event%22%20style%3D%22background-color%3A%20%23ffffff%3B%22%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2FAzure-Database-for-MySQL%2FAzure-brings-intelligence-and-high-performance-to-Azure-Database%2Fba-p%2F769110%22%20target%3D%22_self%22%3EAzure%20brings%20intelligence%20and%20high%20performance%20to%20Azure%20Database%20for%20MySQL%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%3CSTRONG%3E3-%20Enable%20Slow%20Query%20Log%3C%2FSTRONG%3E%3A%26nbsp%3B%26nbsp%3BSlow%20query%20log%20can%20be%20used%20to%20identify%20performance%20bottlenecks%20for%20troubleshooting%2C%20this%20will%20drill%20issue%20down%20into%20the%20query%20level%20to%20show%20how%20long%20each%20query%20took%20to%20execute%26nbsp%3Band%20this%20will%20help%20to%20identify%20an%20action%20lan%20to%20resolve%20the%20issue%2C%20to%20enable%20this%20please%20view%20this%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fmysql%2Fconcepts-server-logs%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Edocumentation%3C%2FA%3E.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3E4-%26nbsp%3B%3C%2FSTRONG%3E%3CSPAN%3E%3CSTRONG%3EQuery%20Store%3A%3C%2FSTRONG%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fmysql%2Fconcepts-query-store%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EThe%20Query%20Store%3C%2FA%3Efeature%20in%20Azure%20Database%20for%20MySQL%20provides%20a%20way%20to%20track%20query%20performance%20over%20time.%20Query%20Store%20simplifies%20performance%20troubleshooting%20by%20helping%20you%20quickly%20find%20the%20longest%20running%20and%20most%20resource-intensive%20queries.%20Query%20Store%20automatically%20captures%20a%20history%20of%20queries%20and%20runtime%20statistics%2C%20and%20it%20retains%20them%20for%20your%20review.%20It%20separates%20data%20by%20time%20windows%20so%20that%20you%20can%20see%20database%20usage%20patterns.%20Data%20for%20all%20users%2C%20databases%2C%20and%20queries%20is%20stored%20in%20the%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3Emysql%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3Bschema%20database%20in%20the%20Azure%20Database%20for%20MySQL%20instance.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3E%3CFONT%20size%3D%223%22%3E5-%20Use%20the%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fmysql%2Fhowto-troubleshoot-query-performance%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EEXPLAIN%20%3C%2FA%3Ecommand%3C%2FFONT%3E%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%223%22%3EEXPLAIN%20is%20used%20to%20obtain%20a%20query%20execution%20plan%20(that%20is%2C%20an%20explanation%20of%20how%20MySQL%20would%20execute%20a%20query.%20This%20can%20help%20understand%20the%20bottleneck%20in%20a%20specific%20query.%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3EPlease%20view%20the%20following%20tutorial%20on%20E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fmysql%2Fhowto-troubleshoot-query-performance%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EXPLAIN%20to%20profile%20query%20performance%20in%20Azure%20Database%20for%20MySQL.%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3E6-%20Use%20the%20SHOW%20PROFILE%20command%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%223%22%3E%3CA%20href%3D%22https%3A%2F%2Fdev.mysql.com%2Fdoc%2Frefman%2F5.7%2Fen%2Fshow-profile.html%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3ESHOW%20PROFILE%3C%2FA%3Eand%20%3CA%20href%3D%22https%3A%2F%2Fdev.mysql.com%2Fdoc%2Frefman%2F5.7%2Fen%2Fshow-profiles.html%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3ESHOW%20PROFILES%3C%2FA%3Estatements%20display%20profiling%20information%20that%20indicates%20resource%20usage%20for%20statements%20executed%20during%20the%20course%20of%20the%20current%20session.%20Profiling%20is%20enabled%20per%20session.%20When%20a%20session%20ends%2C%20its%20profiling%20information%20is%20lost.%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1056856%22%20slang%3D%22en-US%22%3ERe%3A%20Azure%20Database%20for%20MySQL%20Performance%20Troubleshooting%20Basics%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1056856%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F288088%22%20target%3D%22_blank%22%3E%40Bashar-MSFT%3C%2FA%3E%26nbsp%3B%20The%20blog%20recommends%20Accelerated%20Networking%2C%20but%20when%20looking%20at%20the%20Accelerated%20Networking%20page%20it%20states%20the%20following%2C%26nbsp%3B%3C%2FP%3E%3CP%3E%3CEM%3E%3CSPAN%3E%26nbsp%3BWhen%20communicating%20across%20VNets%20or%20connecting%20on-premises%2C%20this%20feature%20has%20minimal%20impact%20to%20overall%20latency.%3C%2FSPAN%3E%3C%2FEM%3E%3C%2FP%3E%3CP%3Ewhich%20statement%20is%20correct%3F%26nbsp%3B%20obviously%20we%20will%20load%20test%20with%20and%20without%2C%20but%20from%20the%20Accelerated%20Networking%20page%20it%20shouldn't%20make%20much%20difference%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1059166%22%20slang%3D%22en-US%22%3ERe%3A%20Azure%20Database%20for%20MySQL%20Performance%20Troubleshooting%20Basics%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1059166%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F199652%22%20target%3D%22_blank%22%3E%40David%20Beleznay%3C%2FA%3E%26nbsp%3BThanks%20for%20the%20feedback%20David%2C%20I'm%20happy%20to%20hear%20more%20about%20the%20test%20results%2C%20some%20customer%20noticed%20enhanced%20performance%20if%20they%20enabled%26nbsp%3B%3CSPAN%3EAccelerated%20Networking%20and%20that's%20why%20I%20added%20it%20here%20as%20a%20best%20practice.%20I'm%20looking%20forward%26nbsp%3Bto%20hearing%20from%20you%20on%20the%20test%20results.%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E
Microsoft

If you are facing Performance problems with Azure Database for MySQL, these can often be resolved by doing basic troubleshooting steps to understand the cause of the bottleneck and then explore the options to fix it.

 

Server Level Troubleshooting

1- Resource Utilization: It's very important to start by making sure that you are not maxing out any of your resource limits, reaching high levels of resource utilization will cause a performance issue this can

 be avoided by monitoring server's resource utilization on the Azure Portal.

In Azure Database for MySQL resource limits determined by the service tier that you are using and the number of vCores and Storage size that you provision all this information is documented here and here, you can navigate to your Azure Database for MySQL and use the Metrics blade to check if you are maxing out any of your resource limits. 

mysql metrics.jpg

 

2- Consider ANALYZE and OPTIMIZE all database tables frequently

Analyze: Performs a key distribution analysis and stores the distribution for the named table or tables, clears table statistics from the "INFORMATION_SCHEMA.INNODB_TABLESTATS" table and sets the "STATS_INITIALIZED" column to Uninitialized. Statistics are collected again the next time the table is accessed, this will help pushing a better execution plans for your queries if the data in the table was modified recently.
reference: ANALYZE TABLE

 

OptimizeOnce your data reaches a stable size, or a growing table has increased by tens or some hundreds of megabytes, consider using the OPTIMIZE TABLE statement to reorganize the table and compact any wasted space. The reorganized tables require less disk I/O to perform full table scans. This is a straightforward technique that can improve performance when other techniques such as improving index usage or tuning application code are not practical.In short this will reorganizes the physical storage of table data and associated index data, to reduce storage space and improve I/O efficiency when accessing the table. 

reference: Optimizing Storage Layout for InnoDB Tables

 

3- Make sure you are applying Application side best practices

a) Connection pooling: This significantly reduces connection latency by reusing existing connections and enables higher database throughput (transactions per second) on the server.

b) Accelerated Networking: enables single root I/O virtualization (SR-IOV) to a VM, greatly improving its networking performance. This high-performance path bypasses the host from the datapath, reducing latency, jitter, and CPU utilization, for use with the most demanding network workloads on supported VM types.

c) Application and Database should be in the same Data Center.

 

4- Tune server parameters to better serve your application workload

Azure Database for MySQL allows you to configure server parameters for the values that better serve your workload, check this documentation to learn how. Each application has best practices for those parameter, please review those in order to get the best out of the database server. Some of the parameters that you might need to check is:

a- innodb_buffer_pool_size:
The buffer pool is where data and indexes are cached: having it as large as possible will ensure you use memory and not disks for most read operations.

b- innodb_file_per_table: 
By default, InnoDB tables are stored in the system tablespace. As an alternative, you can store each InnoDB table in its own data file. This feature is called “file-per-table tablespaces” because each table has its own tablespace data file (.ibd file). learn more about it's advantages here.

c- query_cache_size
The amount of memory allocated for caching query results. by default this is turned OFF, read more about this here.

d- log_bin
The server logs all statements that change data to the binary log, which is used for replication, If you don't have replication enabled please make sure the you have this parameter turned OFF.

e- query_store_capture_mode= NONE

Query store capture can help you identify your top consumers and wit statistics but this also adds overhead in terms of performance as the background process will be be collecting data all the time.

f- slow_query_log= OFF
Turning slow query log off will save data collection overhead which contributes to better performance, if you don't need low query log turn off and you can enable it later if needed.

g- log_queries_not_using_indexes= OFF

This parameter helps you determine missing indexes, while its awesome to learn about missing indexes but keeping this parameter enabled all the time will drop query performance significantly, rule of thumb here is to use it when you need it. 

 

Query Level Troubleshooting

Use Microsoft Intelligent Performance tools to explore queries that are considered top consumers and also learn about missing indexes along with recommendation and full analysis for your workload. Intelligent Performance for Azure Database for MySQL includes (QPI, Performance Recommendations, Slow query log):

 

1- Leverage Query Performance Insight (QPI)
Query Performance Insight helps you to quickly identify what your longest running queries are, how they change over time, and what waits are affecting them, this can help you determine problematic queries. Tutorial on how to use QPI can be found here

2- Use Performance Recommendations feature

The Performance Recommendations feature analyzes your databases to create customized suggestions for improved performance. To produce the recommendations, the analysis looks at various database characteristics including schema. you can read more about this here.

Please consider also to read 
Azure brings intelligence and high performance to Azure Database for MySQL

 

3- Enable Slow Query Log:  Slow query log can be used to identify performance bottlenecks for troubleshooting, this will drill issue down into the query level to show how long each query took to execute and this will help to identify an action lan to resolve the issue, to enable this please view this documentation.

 

4- Query Store: The Query Store feature in Azure Database for MySQL provides a way to track query performance over time. Query Store simplifies performance troubleshooting by helping you quickly find the longest running and most resource-intensive queries. Query Store automatically captures a history of queries and runtime statistics, and it retains them for your review. It separates data by time windows so that you can see database usage patterns. Data for all users, databases, and queries is stored in the mysql schema database in the Azure Database for MySQL instance.

 

5- Use the EXPLAIN command

EXPLAIN is used to obtain a query execution plan (that is, an explanation of how MySQL would execute a query. This can help understand the bottleneck in a specific query.

Please view the following tutorial on EXPLAIN to profile query performance in Azure Database for MySQL.

 

6- Use the SHOW PROFILE command

SHOW PROFILE and SHOW PROFILES statements display profiling information that indicates resource usage for statements executed during the course of the current session. Profiling is enabled per session. When a session ends, its profiling information is lost.

 

 

 

2 Comments

@Bashar-MSFT  The blog recommends Accelerated Networking, but when looking at the Accelerated Networking page it states the following, 

 When communicating across VNets or connecting on-premises, this feature has minimal impact to overall latency.

which statement is correct?  obviously we will load test with and without, but from the Accelerated Networking page it shouldn't make much difference?

 

Microsoft

@David Beleznay Thanks for the feedback David, I'm happy to hear more about the test results, some customer noticed enhanced performance if they enabled Accelerated Networking and that's why I added it here as a best practice. I'm looking forward to hearing from you on the test results.