Home
%3CLINGO-SUB%20id%3D%22lingo-sub-563444%22%20slang%3D%22en-US%22%3EDo%20you%20need%20more%20memory%20on%20Azure%20SQL%20Managed%20Instance%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-563444%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSPAN%20style%3D%22background-color%3A%20%23ffffff%3B%20box-sizing%3A%20border-box%3B%20color%3A%20%23333333%3B%20cursor%3A%20text%3B%20display%3A%20inline%3B%20float%3A%20none%3B%20font-family%3A%20inherit%3B%20font-size%3A%2016px%3B%20font-style%3A%20normal%3B%20font-variant%3A%20normal%3B%20font-weight%3A%20300%3B%20letter-spacing%3A%20normal%3B%20line-height%3A%201.7142%3B%20orphans%3A%202%3B%20text-align%3A%20left%3B%20text-decoration%3A%20none%3B%20text-indent%3A%200px%3B%20text-transform%3A%20none%3B%20-webkit-text-stroke-width%3A%200px%3B%20white-space%3A%20normal%3B%20word-spacing%3A%200px%3B%22%3EAzure%20SQL%20Managed%20Instance%20is%20a%20fully-managed%20SQL%20Server%20database%20engine%20where%20you%20can%20easily%20choose%20the%20size%20of%20the%20instance%20with%20the%20amount%20of%20resources%20you%20want%20to%20use.%3C%2FSPAN%3E%3CSPAN%20style%3D%22display%3A%20inline%20!important%3B%20float%3A%20none%3B%20background-color%3A%20%23ffffff%3B%20color%3A%20%23333333%3B%20cursor%3A%20text%3B%20font-family%3A%20inherit%3B%20font-size%3A%2016px%3B%20font-style%3A%20normal%3B%20font-variant%3A%20normal%3B%20font-weight%3A%20300%3B%20letter-spacing%3A%20normal%3B%20line-height%3A%201.7142%3B%20orphans%3A%202%3B%20text-align%3A%20left%3B%20text-decoration%3A%20none%3B%20text-indent%3A%200px%3B%20text-transform%3A%20none%3B%20-webkit-text-stroke-width%3A%200px%3B%20white-space%3A%20normal%3B%20word-spacing%3A%200px%3B%22%3E%20Sometime%2C%20it%20is%20hard%20to%20determine%20what%20instance%20size%20you%20need%20to%20use%20for%20your%20workload%20and%20one%20of%20the%20criteria%20might%20be%20the%20amount%20of%20memory%20that%20you%20need.%20This%20article%20enables%20you%20to%20check%20do%20you%20have%20enough%20memory%20on%20your%20Azure%20SQL%20Managed%20Instance.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20amount%20of%20memory%20available%20to%20Managed%20Instance%20is%20proportional%20to%20the%20number%20of%20cores%20assigned.%20As%20an%20example%2C%20in%20the%20Gen5%20architecture%20you%20have%205.1GB%20of%20memory%20per%20vCore%2C%20meaning%20that%208-core%20instance%20will%20have%2041GB%20memory.%20Periodically%20you%20should%20check%20if%20this%20amount%20of%20memory%20is%20the%20right%20match%20for%20your%20workload.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EDo%20not%20be%20tempted%20to%20just%20monitor%20the%20Managed%20Instance%20use.%20It%20will%20be%20about%20100%25%20of%20available%20memory.%20Some%20people%20believe%20that%20this%20is%20an%20issue%20(like%20hitting%20100%25%20CPU)%2C%20but%20this%20is%20expected%20and%20desired%20behavior.%20Managed%20Instance%20should%20use%20as%20much%20memory%20as%20possible%20to%20cache%20the%20pages%20from%20disk%20into%20the%20buffer%20pool.%20The%20only%20case%20where%20you%20will%20not%20see%20near%20100%25%20usage%20of%20memory%20is%20the%20case%20where%20you%20have%20databases%20much%20smaller%20than%20the%20available%20memory%20size%20so%20all%20of%20them%20fit%20into%20memory.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20better%20metric%20for%20memory%20usage%20monitoring%20is%20%E2%80%98Page%20Life%20Expectancy%E2%80%99%20(PLE)%20performance%20counter%20%3CA%20href%3D%22https%3A%2F%2Fwww.sqlskills.com%2Fblogs%2Fpaul%2Fpage-life-expectancy-isnt-what-you-think%2F%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Emonitored%20on%20NUMA%20nodes%3C%2FA%3E.%20Page%20Life%20Expectancy%20indicates%20how%20many%20seconds%20the%20pages%20live%20in%20the%20memory%20before%20they%20are%20flushed%20back%20to%20disk.%20The%20higher%20this%20value%20is%2C%20the%20better%2C%20but%20you%20need%20to%20determine%20what%20the%20limit%20is.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ESome%20people%20believe%20that%20PLE%20value%20should%20be%20greater%20than%20300%2C%20but%20this%20is%20a%20old%20rule%20created%20for%20computers%20with%204GB%20memory%20and%20criticized%20by%20people%20like%20%3CA%20href%3D%22https%3A%2F%2Fwww.sqlskills.com%2Fblogs%2Fjonathan%2Ffinding-what-queries-in-the-plan-cache-use-a-specific-index%2F%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%20data-href%3D%22https%3A%2F%2Fwww.sqlskills.com%2Fblogs%2Fjonathan%2Ffinding-what-queries-in-the-plan-cache-use-a-specific-index%2F%22%3EJonathan%20Kehayias%3C%2FA%3E.%20In%20modern%20architectures%20with%20more%20memory%2C%20you%20should%20increase%20this%20limit%20and%20find%20the%20value%20%3CSTRONG%3Eproportional%20to%20the%20buffer%20pool%20memory%3C%2FSTRONG%3E.%20As%20an%20example%2C%20if%20you%20have%208-core%20Managed%20Instance%20(with%20~40GB%20memory)%20and%20if%20the%20buffer%20pool%20uses%20all%20of%20the%2040GB%20memory%20(which%20is%20highly%20unlikely%20because%20memory%20should%20be%20allocated%20to%20other%20processes%20and%20components)%20your%20PLE%20might%20go%20up%20to%203000%20instead%20of%20300.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThere%20is%20an%20article%20written%20by%20%3CA%20href%3D%22https%3A%2F%2Fblogs.msdn.microsoft.com%2Fmcsukbi%2F2013%2F04%2F11%2Fsql-server-page-life-expectancy%2F%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3E%3CSPAN%20style%3D%22color%3A%20%23333333%3B%20font-family%3A%20'Segoe%20UI'%2C%20Tahoma%2C%20Arial%2C%20'Helvetica%20Neue'%2C%20Helvetica%2C%20sans-serif%3B%20font-size%3A%2014px%3B%20font-style%3A%20normal%3B%20font-variant-ligatures%3A%20normal%3B%20font-variant-caps%3A%20normal%3B%20font-weight%3A%20400%3B%20letter-spacing%3A%20normal%3B%20orphans%3A%202%3B%20text-align%3A%20start%3B%20text-indent%3A%200px%3B%20text-transform%3A%20none%3B%20white-space%3A%20normal%3B%20widows%3A%202%3B%20word-spacing%3A%200px%3B%20-webkit-text-stroke-width%3A%200px%3B%20background-color%3A%20%23ffffff%3B%20text-decoration-style%3A%20initial%3B%20text-decoration-color%3A%20initial%3B%20display%3A%20inline%20!important%3B%20float%3A%20none%3B%22%3EDavid%20Williams%20and%3C%2FSPAN%3E%3C%2FA%3E%3CSPAN%20style%3D%22color%3A%20%23333333%3B%20font-family%3A%20'Segoe%20UI'%2C%20Tahoma%2C%20Arial%2C%20'Helvetica%20Neue'%2C%20Helvetica%2C%20sans-serif%3B%20font-size%3A%2014px%3B%20font-style%3A%20normal%3B%20font-variant-ligatures%3A%20normal%3B%20font-variant-caps%3A%20normal%3B%20font-weight%3A%20400%3B%20letter-spacing%3A%20normal%3B%20orphans%3A%202%3B%20text-align%3A%20start%3B%20text-indent%3A%200px%3B%20text-transform%3A%20none%3B%20white-space%3A%20normal%3B%20widows%3A%202%3B%20word-spacing%3A%200px%3B%20-webkit-text-stroke-width%3A%200px%3B%20background-color%3A%20%23ffffff%3B%20text-decoration-style%3A%20initial%3B%20text-decoration-color%3A%20initial%3B%20display%3A%20inline%20!important%3B%20float%3A%20none%3B%22%3E%3CA%20href%3D%22https%3A%2F%2Fblogs.msdn.microsoft.com%2Fmcsukbi%2F2013%2F04%2F11%2Fsql-server-page-life-expectancy%2F%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3E%20Matthew%20Robertshaw%3C%2FA%3E%20explaining%20how%20to%20determine%20limits%20and%20calculate%20minimal%20page%20life%20expectancy%20using%20performance%20counters.%20The%20formula%20they%20provided%20is%20used%20in%20this%20SQL%20query%3A%3C%2FSPAN%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3Eselect%20v.object_name%2C%0A%20%20bp_mem_gb%20%3D%20(l.cntr_value*8%2F1024)%2F1024%2C%20%0A%20%20ple%20%3D%20v.cntr_value%2C%20%0A%20%20min_ple%20%3D%20(((l.cntr_value*8%2F1024)%2F1024)%2F4)*300%0Afrom%20sys.dm_os_performance_counters%20v%0Ajoin%20sys.dm_os_performance_counters%20l%20on%20v.object_name%20%3D%20l.object_name%0Awhere%20v.counter_name%20%3D%20'Page%20Life%20Expectancy'%0Aand%20l.counter_name%20%3D%20'Database%20pages'%0Aand%20l.object_name%20like%20'%25Buffer%20Node%25'%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThis%20query%20will%20return%20the%20current%20value%20of%20PLE%2C%20the%20amount%20of%20buffer%20pool%20memory%2C%20and%20the%20minimal%20PLE%20value%20calculated%20based%20on%20the%20buffer%20pool%20memory%20value.%3C%2FP%3E%0A%3CP%3EIf%20you%20run%20this%20query%20on%20your%20Managed%20Instance%20and%20you%20are%20frequently%20getting%20PLE%20below%20minimal%20PLE%20value%2C%20you%20might%20consider%20upscaling%20your%20instance%20to%20a%20higher%20tier.%3C%2FP%3E%0A%3CBLOCKQUOTE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3ENOTE%3A%3C%2FSTRONG%3E%20Try%20to%20identify%20the%20queries%20that%20are%20using%20a%20lot%20of%20memory%20before%20you%20add%20more%20cores.%20It%20is%20possible%20that%20there%20are%20some%20queries%20that%20are%20cause%20memory%20pressure%20or%20use%20more%20memory%20than%20usual.%20If%20you%20identify%20and%20fix%20these%20queries%20you%20would%20not%20need%20to%20up-scale%20your%20instance.%3C%2FP%3E%0A%3C%2FBLOCKQUOTE%3E%0A%3CP%20style%3D%22box-sizing%3A%20border-box%3B%20color%3A%20%23333333%3B%20font-family%3A%20inherit%3B%20font-size%3A%2016px%3B%20font-style%3A%20normal%3B%20font-variant%3A%20normal%3B%20font-weight%3A%20300%3B%20letter-spacing%3A%20normal%3B%20line-height%3A%201.7142%3B%20orphans%3A%202%3B%20text-align%3A%20left%3B%20text-decoration%3A%20none%3B%20text-indent%3A%200px%3B%20text-transform%3A%20none%3B%20-webkit-text-stroke-width%3A%200px%3B%20white-space%3A%20normal%3B%20word-spacing%3A%200px%3B%20margin%3A%200px%3B%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22box-sizing%3A%20border-box%3B%20color%3A%20%23333333%3B%20font-family%3A%20inherit%3B%20font-size%3A%2016px%3B%20font-style%3A%20normal%3B%20font-variant%3A%20normal%3B%20font-weight%3A%20300%3B%20letter-spacing%3A%20normal%3B%20line-height%3A%201.7142%3B%20orphans%3A%202%3B%20text-align%3A%20left%3B%20text-decoration%3A%20none%3B%20text-indent%3A%200px%3B%20text-transform%3A%20none%3B%20-webkit-text-stroke-width%3A%200px%3B%20white-space%3A%20normal%3B%20word-spacing%3A%200px%3B%20margin%3A%200px%3B%22%3EYou%20don't%20need%20to%20immediately%20upgrade%20service%20tier%20and%20add%20more%20memory%20as%20soon%20as%20you%20identify%20this%20issue.%20This%20parameter%20is%20not%20the%20exact%20proof%20that%20you%20need%20more%20memory%2C%20but%20it%20is%20good%20indicator%20and%20you%20should%20investigate%20it.%20You%20should%20check%20wait%20statistics%20using%20DMVs%20like%20it%20is%20shown%20in%20the%20following%20code%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3EDBCC%20SQLPERF('sys.dm_os_wait_stats'%2C%20CLEAR)%3B%0A--%20wait%20some%20time%0Aselect%20top%2010%20wait_type%2C%20wait_time_ms%20from%20sys.dm_os_wait_stats%20order%20by%20wait_time_ms%20desc%3C%2FPRE%3E%0A%3CP%3EAs%20an%20alternative%2C%20you%20can%20use%20SQL%20Server%20Management%20Studio%20%3CA%20href%3D%22https%3A%2F%2Fblogs.msdn.microsoft.com%2Fsql_server_team%2Fnew-in-ssms-performance-dashboard-built-in%2F%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3EPerformance%20Dashboard%3C%2FA%3E%2C%20SentryOne%20%3CFONT%20style%3D%22background-color%3A%20%23ffffff%3B%22%3E%3CA%20href%3D%22https%3A%2F%2Fwww.sentryone.com%2Fwhite-papers%2Ftroubleshooting-sql-server-wait-stats%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3EPerformance%20Analysis%20Dashboard%3C%2FA%3E%2C%20%3C%2FFONT%3E%3CA%20href%3D%22https%3A%2F%2Fsolutioncenter.apexsql.com%2Fsql-server-performance-monitoring-identifying-problems-using-wait-statistics-and-query-wait-analysis%2F%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3EApexSQL%20Monitor%3C%2FA%3E%20or%20other%20tools%20and%20see%20are%20there%20any%20PAGIOLATCH%20wait%20statistics%20that%20can%20indicate%20that%20Managed%20Instance%20is%20waiting%20for%20some%20pages%20to%20be%20loaded.%3C%2FP%3E%0A%3CP%3EIn%20addition%2C%20you%20can%20check%20memory%20distribution%20and%20see%20whether%20or%20components%20use%20more%20memory%20than%20expected.%20It%20is%20possible%20that%20there%20is%20some%20other%20component%20such%20as%20plan%20cache%20or%20columnstore%20pool%20that%20is%20using%20more%20memory%20and%20removing%20the%20pages%20from%20the%20buffer%20pool.%20There%20are%20other%20parameters%20that%20you%20can%20monitor%20and%20you%20can%20find%20more%20information%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fsql%2Frelational-databases%2Fperformance-monitor%2Fmonitor-memory-usage%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3Ehere%3C%2FA%3E.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-563444%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSPAN%20style%3D%22display%3A%20inline%20!important%3B%20float%3A%20none%3B%20background-color%3A%20%23ffffff%3B%20color%3A%20%23333333%3B%20cursor%3A%20text%3B%20font-family%3A%20inherit%3B%20font-size%3A%2016px%3B%20font-style%3A%20normal%3B%20font-variant%3A%20normal%3B%20font-weight%3A%20300%3B%20letter-spacing%3A%20normal%3B%20line-height%3A%201.7142%3B%20orphans%3A%202%3B%20text-align%3A%20left%3B%20text-decoration%3A%20none%3B%20text-indent%3A%200px%3B%20text-transform%3A%20none%3B%20-webkit-text-stroke-width%3A%200px%3B%20white-space%3A%20normal%3B%20word-spacing%3A%200px%3B%22%3EAzure%20SQL%20Managed%20Instance%20is%20a%20fully-managed%20SQL%20Server%20database%20engine%20where%20you%20can%20easily%20choose%20size%20of%20the%20instance%20with%20the%20amount%20of%20resources%20you%20want%20to%20use.%3C%2FSPAN%3E%20Sometime%20it%20is%20hard%20to%20determine%20what%20instance%20size%20you%20need%20to%20use%20for%20your%20workload%20and%20one%20of%20the%20criteria%20might%20be%20the%20amount%20of%20memory%20that%20you%20need.%20This%20article%20enables%20you%20to%20check%20do%20you%20have%20enough%20memory%20on%20your%20Azure%20SQL%20Managed%20Instance.%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-563444%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EMaintenance%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EManaged%20Instance%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EPerformance%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Microsoft

Azure SQL Managed Instance is a fully-managed SQL Server database engine where you can easily choose the size of the instance with the amount of resources you want to use. Sometime, it is hard to determine what instance size you need to use for your workload and one of the criteria might be the amount of memory that you need. This article enables you to check do you have enough memory on your Azure SQL Managed Instance.

 

The amount of memory available to Managed Instance is proportional to the number of cores assigned. As an example, in the Gen5 architecture you have 5.1GB of memory per vCore, meaning that 8-core instance will have 41GB memory. Periodically you should check if this amount of memory is the right match for your workload.

 

Do not be tempted to just monitor the Managed Instance use. It will be about 100% of available memory. Some people believe that this is an issue (like hitting 100% CPU), but this is expected and desired behavior. Managed Instance should use as much memory as possible to cache the pages from disk into the buffer pool. The only case where you will not see near 100% usage of memory is the case where you have databases much smaller than the available memory size so all of them fit into memory.

 

The better metric for memory usage monitoring is ‘Page Life Expectancy’ (PLE) performance counter monitored on NUMA nodes. Page Life Expectancy indicates how many seconds the pages live in the memory before they are flushed back to disk. The higher this value is, the better, but you need to determine what the limit is.

 

Some people believe that PLE value should be greater than 300, but this is a old rule created for computers with 4GB memory and criticized by people like Jonathan Kehayias. In modern architectures with more memory, you should increase this limit and find the value proportional to the buffer pool memory. As an example, if you have 8-core Managed Instance (with ~40GB memory) and if the buffer pool uses all of the 40GB memory (which is highly unlikely because memory should be allocated to other processes and components) your PLE might go up to 3000 instead of 300.

 

There is an article written by David Williams and Matthew Robertshaw explaining how to determine limits and calculate minimal page life expectancy using performance counters. The formula they provided is used in this SQL query: 

 

select	v.object_name,
		bp_mem_gb = (l.cntr_value*8/1024)/1024, 
		ple = v.cntr_value, 
		min_ple = (((l.cntr_value*8/1024)/1024)/4)*300
from sys.dm_os_performance_counters v
join sys.dm_os_performance_counters l on v.object_name = l.object_name
where v.counter_name = 'Page Life Expectancy'
and l.counter_name = 'Database pages'
and l.object_name like '%Buffer Node%'

 

This query will return the current value of PLE, the amount of buffer pool memory, and the minimal PLE value calculated based on the buffer pool memory value.

If you run this query on your Managed Instance and you are frequently getting PLE below minimal PLE value, you might consider upscaling your instance to a higher tier.

 

NOTE: Try to identify the queries that are using a lot of memory before you add more cores. It is possible that there are some queries that are cause memory pressure or use more memory than usual. If you identify and fix these queries you would not need to up-scale your instance.

 

You don't need to immediately upgrade service tier and add more memory as soon as you identify this issue. This parameter is not the exact proof that you need more memory, but it is good indicator and you should investigate it. You should check wait statistics using DMVs like it is shown in the following code:

 

DBCC SQLPERF('sys.dm_os_wait_stats', CLEAR);
-- wait some time
select top 10 wait_type, wait_time_ms from sys.dm_os_wait_stats order by wait_time_ms desc

As an alternative, you can use SQL Server Management Studio Performance Dashboard, SentryOne Performance Analysis Dashboard, ApexSQL Monitor or other tools and see are there any PAGIOLATCH wait statistics that can indicate that Managed Instance is waiting for some pages to be loaded.

In addition, you can check memory distribution and see whether or components use more memory than expected. It is possible that there is some other component such as plan cache or columnstore pool that is using more memory and removing the pages from the buffer pool. There are other parameters that you can monitor and you can find more information here.