Skip to content

Instantly share code, notes, and snippets.

View jacobhackl's full-sized avatar

Jacob Hackl jacobhackl

  • minneapolis, mn
View GitHub Profile
@jacobhackl
jacobhackl / gist:1057159
Created June 30, 2011 20:31
SQL Activity mon query
--from http://sqlblog.com/blogs/john_paul_cook/archive/2009/08/24/using-the-processes-query-outside-of-activity-monitor.aspx
/* ACTIVITY MONITOR */
/* Processes */
SELECT
[Session ID] = s.session_id,
@jacobhackl
jacobhackl / SlowQueries
Created June 30, 2011 20:27
Find slow queries
SELECT creation_time
,last_execution_time
,total_physical_reads
,total_logical_reads
,total_logical_writes
, execution_count
, total_worker_time
, total_elapsed_time
, total_elapsed_time / execution_count avg_elapsed_time
,SUBSTRING(st.text, (qs.statement_start_offset/2) + 1,
@jacobhackl
jacobhackl / gist:976723
Created May 17, 2011 15:48
Deeper reindex from MFST...not as good as my old one
SET NOCOUNT ON;
DECLARE @tablename varchar(255);
DECLARE @execstr varchar(400);
DECLARE @objectid int;
DECLARE @indexid int;
DECLARE @frag decimal;
DECLARE @maxfrag decimal;
-- Decide on the maximum fragmentation to allow for.
SELECT @maxfrag = 30.0;
@jacobhackl
jacobhackl / Terminal open
Created February 7, 2011 20:33
I forget this all the time
open .
@jacobhackl
jacobhackl / SQL Server memory check
Created January 30, 2011 22:34
Quick sql server check for memory
exec sp_configure
SELECT
( CASE WHEN ( [is_modified] = 1 ) THEN 'Dirty' ELSE 'Clean' END ) AS 'Page State' ,
( CASE WHEN ( [database_id] = 32767 ) THEN 'Resource Database' ELSE DB_NAME ( database_id ) END ) AS 'Database Name' ,
COUNT (*) AS 'Page Count'
FROM sys . dm_os_buffer_descriptors
GROUP BY [database_id] , [is_modified]
ORDER BY [database_id] , [is_modified] ;
GO