Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

What are the consumers of MPA (multi page allocations) in SQL Server?

I know data pages are always 8K. Is there a situation where data/index page make use of MPA? It makes sense that execution plans can use MPA as they can exceed 8 KB.

There is a blog here that suggests use of MPA but it refers to stored procedures (one with 500 parameters). In the attached screenshot I see an execution plan using around 11 MB; does this use MPA? Is there a way to confirm that memory allocation for the execution plan is using multi page allocation?

enter image description here

My confusion is what actually uses MPA (multi page allocator). The example in the link I posted shows a complex execution plan which will require contiguous allocation over 8 KB.

An answer below suggests that there are many things like linked server or extended stored procedures that can use MPA. Which for some reason I am not able to agree. For example Extended Stored procedures can be C++ code using HeapAlloc which SQL server has little control over to manage its memory (it has to be at Windows OS level).

Extended stored procedures even in SQL 2012 still consumes memory outside buffer pool so it has to nothing to do with multi page allocation. The same applies to Linked servers especially if you use third party providers (e.g. ORACLE).

share|improve this question
4  
Any contiguous allocation over 8k must come from MPA –  Remus Rusanu May 14 '13 at 13:34
    
Remus, does circle in Red in above is allocated through MPA? –  SQL Learner May 14 '13 at 17:32
4  
Not necessarily. That is a total sum, it can consist of several allocation. You should look at sys.dm_os_memory_clerks.multi_pages_kb –  Remus Rusanu May 14 '13 at 18:53
add comment

1 Answer

up vote 5 down vote accepted

In SQL Server 2008 R2 and earlier, the following allocations come from the MemToLeave (MTL) area:

  • Linked servers
  • XML documents
  • Extended stored procedures
  • sp_OACreate calls
  • Query plans that exceed 8KB
  • SQLCLR
  • Backups that use a large value for MAXTRANSFERSIZE
  • Using a network packet size over 8192 bytes

Information extracted from this article by Microsoft support engineer Amit Banerjee.

SQL Server 2012 uses the Any Size Page Allocator.

Further information is included in this Microsoft Knowledge Base article.

KB extract

Multi-page allocations (MPA) also come from the MTL area, before SQL Server 2012. Whether an allocation made by SQL Server is made via the MPA or single page allocator (SPA) depends purely on the size of the allocation request. If it is 8KB or less, it is allocated via SPA and stolen from the buffer pool. If it is 8KB or more, MPA is used.

I know data page is always 8K so is there a situation where data/index page make use of MPA?

No, data and index pages are always cached in the buffer pool.

Is there a way to confirm that memory allocation for the execution plan is using multi page allocation?

Cached plans have a complex structure. Individual allocations within that structure are generally 8KB allocations, but certain queries (generally those that contain long IN lists or many parameters to a stored procedure call) can require an MPA allocation. These are comparatively rare. It is possible to query SQL Server DMVs to determine the split between SPA and MPA for a cached plan.

share|improve this answer
    
it looks like MPA is part of MTL just another consumer MTL your answer suggests otherwise. –  SQL Learner Jul 6 '13 at 15:57
    
@SQLLearner Multi-page allocations (MPA) come from the MemToLeave (MTL) area. I don't think the answer above suggests anything else, but if you point out which bit confused you, I'll happily make it clearer? –  Paul White Jul 6 '13 at 23:36
    
Paul See my update in the question. I could not fit it into the comment due to character limitation. –  SQL Learner Jul 7 '13 at 13:55
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.