Capturing SQL STATISTICS TIME and IO in a table

Is there a way to capture STATISTICS IOand TIMEin T-SQL to access the table?

+3
source share
3 answers

Sorting.

The same statistics as the data SET STATISTICS TIMEis written to the DMV query: sys.dm_exec_query_stats.

DMVs can be requested from T-SQL, just like regular views.

However, they are SET STATISTICS IOrecorded only as cumulative values ​​(last_logical_reads, last_physical_read) per execution, without differentiation for each rowset specified SET STATISTICS IO.

In general, DMVs can serve the same purpose as SET STATISTICS IO.

+4
source

No, not using SET STATISTICS IO ON.

; SQL Profiler . .

+1

, @Remus Rusanu - elapsed_time ( ).

:

CREATE TABLE #times (
    MS BIGINT
);


INSERT INTO #times
SELECT total_elapsed_time
FROM sys.dm_exec_query_stats 
WHERE sql_handle = 0x02000000DEE9FC09E552D1E33008EED4E8732B21E171EC160000000000000000000000000000000000000000;

, total_elapsed_time ( , ), total_rows , , , DMO, , , :

SELECT *
FROM  sys.dm_exec_sql_text (0x02000000DEE9FC09E552D1E33008EED4E8732B21E171EC160000000000000000000000000000000000000000) ;

(, - query_handle . .)

0

Source: https://habr.com/ru/post/1748654/


All Articles