Get-DbaTempdbUsage
View SourceSynopsis
Gets Tempdb usage for running queries.
Description
This function queries DMVs for running sessions using tempdb and returns results if those sessions have user or internal space allocated or deallocated against them.
Syntax
Get-DbaTempdbUsage
[-SqlInstance] <DbaInstanceParameter[]>
[[-SqlCredential] <PSCredential>]
[-EnableException]
[<CommonParameters>]
Examples
Example: 1
PS C:\> Get-DbaTempdbUsage -SqlInstance localhost\SQLDEV2K14
Gets tempdb usage for localhost\SQLDEV2K14
Required Parameters
-SqlInstance
The target SQL Server instance or instances.
| Property | Value |
|---|---|
| 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.
| Property | Value |
|---|---|
| Alias | |
| Required | False |
| Pipeline | false |
| Default Value |
-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.
| Property | Value |
|---|---|
| Alias | |
| Required | False |
| Pipeline | false |
| Default Value | False |
Outputs
PSCustomObject
Returns one object per running session that has allocated or deallocated tempdb space. For sessions with no tempdb allocation activity, no object is returned.
Properties:
- ComputerName: The name of the computer hosting the SQL Server instance
- InstanceName: The SQL Server instance name
- SqlInstance: The full SQL Server instance name (computer\instance)
- Spid: Session ID of the running query (int)
- StatementCommand: The SQL command being executed (SELECT, INSERT, UPDATE, DELETE, etc.)
- QueryText: The actual T-SQL statement text being executed
- ProcedureName: Schema-qualified name of the stored procedure if applicable
- StartTime: DateTime when the request started executing
- CurrentUserAllocatedKB: Current user object allocation in KB for this session (int)
- TotalUserAllocatedKB: Total user object allocation in KB (int)
- UserDeallocatedKB: User object deallocation in KB (int)
- TotalUserDeallocatedKB: Total user object deallocation in KB (int)
- InternalAllocatedKB: Internal object allocation in KB (int)
- TotalInternalAllocatedKB: Total internal object allocation in KB (int)
- InternalDeallocatedKB: Internal object deallocation in KB (int)
- TotalInternalDeallocatedKB: Total internal object deallocation in KB (int)
- RequestedReads: Number of physical read operations performed by the request (int)
- RequestedWrites: Number of write operations performed by the request (int)
- RequestedLogicalReads: Number of logical read operations performed by the request (int)
- RequestedCPUTime: CPU time in milliseconds used by the request (int)
- IsUserProcess: Boolean indicating if the session is a user process (true) or system process (false)
- Status: Current status of the session (running, sleeping, dormant, etc.)
- Database: Name of the database being accessed
- LoginName: SQL Server login name
- OriginalLoginName: Original login name before impersonation if applicable
- NTDomain: Windows domain name if Windows authentication is used
- NTUserName: Windows username if Windows authentication is used
- HostName: Client computer hostname
- ProgramName: Name of the client application (e.g., SQL Server Management Studio, SSMS)
- LoginTime: DateTime when the session logged in
- LastRequestedStartTime: DateTime when the last request started
- LastRequestedEndTime: DateTime when the last request ended
dbatools