Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

sys.dm_db_session_space_usage (Transact-SQL)

Applies To: SQL Server 2014, SQL Server 2016 Preview

Topic Status: Some information in this topic is preview and subject to change in future releases. Preview information describes new features or changes to existing features in Microsoft SQL Server 2016 Community Technology Preview 2 (CTP2).

Returns the number of pages allocated and deallocated by each session for the database.

Note Note

This view is applicable only to the tempdb database.

Applies to: SQL Server (SQL Server 2008 through current version), SQL Database V12, Azure SQL Data Warehouse Public Preview.

Note Note

To call this from SQL Data Warehouse, use the name sys.dm_pdw_nodes_db_session_space_usage.

Column name

Data type




Session ID.

session_id maps to session_id in sys.dm_exec_sessions.



Database ID.



Number of pages reserved or allocated for user objects by this session.



Number of pages deallocated and no longer reserved for user objects by this session.



Number of pages reserved or allocated for internal objects by this session.



Number of pages deallocated and no longer reserved for internal objects by this session.

On SQL Server requires VIEW SERVER STATE permission on the server.

On SQL Database Premium Tiers requires the VIEW DATABASE STATE permission in the database. On SQL Database Standard and Basic Tiers requires the SQL Database admin account.

IAM pages are not included in any of the allocation or deallocation counts reported by this view.

Page counters are initialized to zero (0) at the start of a session. The counters track the total number of pages that have been allocated or deallocated for tasks that are already completed in the session. The counters are updated only when a task ends; they do not reflect running tasks.

A session can have multiple requests active at the same time. A request can start multiple threads, tasks, if it is a parallel query.

For more information about the sessions, requests, and tasks, see sys.dm_exec_sessions (Transact-SQL), sys.dm_exec_requests (Transact-SQL), and sys.dm_os_tasks (Transact-SQL).

User Objects

The following objects are included in the user object page counters:

  • User-defined tables and indexes

  • System tables and indexes

  • Global temporary tables and indexes

  • Local temporary tables and indexes

  • Table variables

  • Tables returned in the table-valued functions

Internal Objects

Internal objects are only in tempdb. The following objects are included in the internal object page counters:

  • Work tables for cursor or spool operations and temporary large object (LOB) storage

  • Work files for operations such as a hash join

  • Sort runs







Community Additions

© 2015 Microsoft