This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- show running queries (pre 9.2) | |
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query | |
FROM pg_stat_activity | |
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%' | |
ORDER BY query_start desc; | |
-- show running queries (9.2) | |
SELECT pid, age(clock_timestamp(), query_start), usename, query | |
FROM pg_stat_activity | |
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- convert all .xel files in a given folder to a single-column table | |
-- (alternatively specify an individual file explicitly) | |
select event_data = convert(xml, event_data) | |
into #eeTable | |
from sys.fn_xe_file_target_read_file(N'd:\killme\extended events\*.xel', null, null, null); | |
-- select from the table | |
select * from #eeTable | |
-- and click on a hyperlink value to see the structure of the xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DECLARE @session_id INT, @sql NVARCHAR (4000); | |
DECLARE database_curs CURSOR FAST_FORWARD FOR | |
SELECT c.session_id | |
FROM sys.dm_exec_connections AS c | |
JOIN sys.dm_exec_sessions AS s ON c.session_id = s.session_id | |
WHERE c.session_id <> @@SPID AND s.is_user_process = 1; | |
OPEN database_curs; | |
FETCH NEXT FROM database_curs INTO @session_id; | |
WHILE (@@fetch_status <> -1) | |
BEGIN |