commands

^

Get-DbaDbMemoryUsage

Author Shawn Melton (@wsmelton), wsmelton.github.io
Availability Windows, Linux, macOS

 

Want to see the source code for this command? Check out Get-DbaDbMemoryUsage on GitHub.
Want to see the Bill Of Health for this command? Check out Get-DbaDbMemoryUsage.

Synopsis

Determine buffer pool usage by database.

Description

This command can be utilized to determine which databases on a given instance are consuming buffer pool memory.

This command is based on query provided by Aaron Bertrand.
Reference: https://www.mssqltips.com/sqlservertip/2393/determine-sql-server-memory-use-by-database-and-object/

Syntax

Get-DbaDbMemoryUsage
    [-SqlInstance] <DbaInstanceParameter[]>
    [[-SqlCredential] <PSCredential>]
    [[-Database] <Object[]>]
    [[-ExcludeDatabase] <Object[]>]
    [-IncludeSystemDb]
    [-EnableException]
    [<CommonParameters>]

 

Examples

 

Example: 1
PS C:\> Get-DbaDbMemoryUsage -SqlInstance sqlserver2014a

Returns the buffer pool consumption for all user databases

Example: 2
PS C:\> Get-DbaDbMemoryUsage -SqlInstance sqlserver2014a -IncludeSystemDb

Returns the buffer pool consumption for all user databases and system databases

Example: 3
PS C:\> Get-DbaDbMemoryUsage -SqlInstance sql1 -IncludeSystemDb -Database tempdb

Returns the buffer pool consumption for tempdb database only

Example: 4
PS C:\> Get-DbaDbMemoryUsage -SqlInstance sql2 -IncludeSystemDb -Exclude 'master','model','msdb','ResourceDb'

Returns the buffer pool consumption for all user databases and tempdb database

Required Parameters

-SqlInstance

The target SQL Server instance or instances.

Alias
Required True
Pipeline true (ByValue)
Default Value

Optional Parameters

-SqlCredential

Login to the target instance using alternative credentials. Accepts PowerShell credentials (Get-Credential).
Windows Authentication, SQL Server Authentication, Active Directory - Password, and Active Directory - Integrated are all supported.
For MFA support, please use Connect-DbaInstance..

Alias
Required False
Pipeline false
Default Value
-Database

The database(s) to process - this list is auto-populated from the server. If unspecified, all databases will be processed.

Alias
Required False
Pipeline true (ByPropertyName)
Default Value
-ExcludeDatabase

The database(s) to exclude.

Alias
Required False
Pipeline false
Default Value
-IncludeSystemDb

Switch to have the output include system database memory consumption.

Alias
Required False
Pipeline false
Default Value False
-EnableException

By default, when something goes wrong we try to catch it, interpret it and give you a friendly warning message.
This avoids overwhelming you with "sea of red" exceptions, but is inconvenient because it basically disables advanced scripting.
Using this switch turns this "nice by default" feature off and enables you to catch exceptions with your own try/catch.

Alias
Required False
Pipeline false
Default Value False