SQL Server data connection pool usage detection

Source: Internet
Author: User
Tags session id

1, according to HOST_NAME request session_id inquiry
Select db_name   host_name from innerjoinon t1.session_id =t2.session_id where host_name= ' zhangshulei-'

Search results:

2, according to SESSION_ID query data connection situation, status
Select sql_handle,* from sys.dm_exec_requests where session_id=57

Search results:

Detailed parameters:

Column Name Data Type Description
session_id smallint ID of the session associated with this request. cannot be a null value.
request_id Int The ID of the request. is unique within the context of the session. cannot be a null value.
Start_time Datetime The time that the request was scheduled to run. cannot be a null value.
Status nvarchar (60) The status of the request. Possible values include the following:
  • Background. The request is a background thread, such as a resource monitor or deadlock monitor.
  • is running. The request is running.
  • can be run. The request is running, and due to the lack of arbitration, a proper arrangement should be made on a temporary basis.
  • Sleep. There's no work to do.
  • Hangs. The request is waiting for a worker thread to pick.
  • is suspended. The request is waiting for an event.
cannot be a null value.
Command nvarchar (+) identifies the type of command being processed. Common command types include:
  • SELECT 
  • INSERT 
  • UPDATE 
  • DELETE 
  • backup log 
  • DBCC 
  • WAITFOR 
by using   sys.dm_exec_sql_text   dynamic management functions and the corresponding   of the request; sql_handle , The text of the request can be retrieved. The internal system processes will set the command based on the type of task they are performing. These tasks can include:
  • LOCK MONITOR< /li>
  • checkpointlazy
  • writer
non-nullable value.
Sql_handle varbinary (64) The SQL statement handle of the request. The handle can be used to retrieve the actual statement text through the Sys.dm_exec_sql_text dynamic management function. cannot be a null value.
Statement_start_offset Int The start character position of the execution statement in the execution batch or stored procedure. Can be used with statement_end_offset,sys.dm_exec_sql_text dynamic management functions, and sql_handle to retrieve executing statements for a request. Can be a null value.
Statement_end_offset Int The end character position of the statement being executed in the execution of the batch or stored procedure. Can be used with statement_start_offset,sys.dm_exec_sql_text dynamic management functions, and sql_handle , Retrieves the statement being executed for the request. Can be a null value.
Plan_handle varbinary (64) The query plan handle for the request. To view the query plan, use the sys.dm_exec_query_plan dynamic management function together. To query the plan cache, use the sys.dm_exec_cached_plans dynamic management view. To view the schedule properties, use the sys.dm_exec_plan_attributes function. Can be a null value.
database_id smallint The ID of the database that is running the request. For detailed database information, query the sys.databases catalog view, or, to get the database name, use the db_name () intrinsic function. cannot be a null value.
user_id Int The user ID that is running the request. For detailed user information, consult the sys.database_principals catalog view. cannot be a null value.
connection_id uniqueidentifier The ID of the connection used when the request arrives. For more information about physical or logical connections, consult the sys.dm_exec_connections dynamic management view. Can be a null value.
blocking_session_id smallint The ID of the session that is blocking the request. If this column is 0, the request is not blocked, or the information for the locked session is not available or cannot be identified. -2 = The blocking resource is owned by an orphaned distributed transaction. -3 = The blocking resource is owned by a deferred recovery transaction. -4 = The session ID of the blocking latch owner cannot be determined due to internal latch state transitions.
Wait_type nvarchar (60) If the request is blocked, this column returns the wait type. Can be a null value.
Wait_time Int If the request is blocked, this column returns the duration of the current wait (in milliseconds). cannot be a null value.
Last_wait_type nvarchar (64) If this request has previously been blocked, this column returns the type of the last wait. cannot be a null value.
Wait_resource nvarchar (512) If the request is blocked, this column returns the resource that is waiting for the request. cannot be a null value.
Open_transaction_count Int The number of transactions opened for this request. cannot be a null value.
Open_resultset_count Int The number of result sets opened for this request. cannot be a null value.
transaction_id bigint The ID of the transaction in which this request was executed. For an instance of SQL Server, the ID is unique. Used to query sys.dm_tran_active_transactions,sys.dm_tran_locks , or sys.dm_tran_database_transactions dynamic management views. cannot be a null value.
Context_info varbinary (128) The value of the requested SET Context_info statement. Can be a null value.
Percent_complete Real The percentage of work done for some operations, including rollback. This operation does not provide progress data for the query.
cannot be a null value.
Estimated_completion_time bigint For internal use only. cannot be a null value.
Cpu_time Int The CPU time (in milliseconds) used by the request. cannot be a null value.
Total_elapsed_time Int The total elapsed time (in milliseconds) after the request arrives. cannot be a null value.
scheduler_id Int The ID of the scheduler that is scheduling this request. For more information about this scheduler, consult the sys.dm_os_schedulers dynamic management view. cannot be a null value.
Task_address varbinary (8) The memory address assigned to the task associated with this request. For more information about this task, consult the sys.dm_os_tasks dynamic management view. Can be a null value.
Reads bigint The number of reads performed by this request. cannot be a null value.
Writes bigint The number of writes performed by this request. cannot be a null value.
Logical_reads bigint The number of logical reads that have been performed by this request. cannot be a null value.
Text_size Int The TEXTSIZE setting for this request. cannot be a null value.
Language nvarchar (256) The language setting for the request. Can be a null value.
Date_format nvarchar (3) The DateFormat setting for the request. Can be a null value.
Date_first smallint The Datefirst setting for the request. cannot be a null value.
Quoted_identifier Bit 1 = QUOTED_IDENTIFIER is on for the request. Otherwise, it is 0. cannot be a null value.
Arithabort Bit 1 = ARITHABORT setting is on for the request. Otherwise, it is 0. cannot be a null value.
ansi_null_dflt_on Bit 1 = ansi_null_dflt_on setting is on for the request. Otherwise, it is 0. cannot be a null value.
Ansi_defaults Bit 1 = ansi_defaults setting is on for the request. Otherwise, it is 0. cannot be a null value.
Ansi_warnings Bit 1 = ansi_warnings setting is on for the request. Otherwise, it is 0. cannot be a null value.
Ansi_padding Bit 1 = ansi_padding setting is on for the request. Otherwise, it is 0. cannot be a null value.
Ansi_nulls Bit 1 = ansi_nulls setting is on for the request. Otherwise, it is 0. cannot be a null value.
Concat_null_yields_null Bit 1 = concat_null_yields_null setting is on for the request. Otherwise, it is 0. cannot be a null value.
Transaction_isolation_level smallint The transaction isolation level for this request. Possible values include: 0 = unspecified 1 = uncommitted Read 2 = Read Committed 3 = repeatable 4 = Serializable 5 = snapshot cannot be null.
Lock_timeout Int The lock timeout (in milliseconds) for this request. cannot be a null value.
Deadlock_priority Int The requested deadlock_priority setting. cannot be a null value.
Row_count bigint The number of rows that have been returned to the client by this request. cannot be a null value.
Prev_error Int The last error that occurred during the execution of the request. cannot be a null value.
Nest_level Int The level of nesting of code that is executing on the request. cannot be a null value.
Granted_query_memory Int The number of pages allocated for the query executing the request. cannot be a null value.
Executing_managed_code Bit Indicates whether this request is executing common language runtime objects, such as routines, types, and triggers. This value is set as long as the common language runtime object is on the stack, even when you run Transact-SQL from the common language runtime. cannot be a null value.

3. Find all currently blocked requests
SELECT session_id, status, blocking_session_id    , Wait_type, Wait_time, Wait_resource     from   WHERE= N'suspended'; GO

SQL Server data connection pool usage detection

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.