Skip to content

Commit 0779c7a

Browse files
author
Ajay Dwivedi
committed
Updated few queries
Updated few queries
1 parent 11e7432 commit 0779c7a

11 files changed

+7681
-4
lines changed
0 Bytes
Binary file not shown.

BlitzQueries/BlitzQueries.ssmssqlproj

+24
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,30 @@
241241
<AssociatedConnUserName />
242242
<FullPath>SQL Server 2008 R2 Diagnostic Information Queries.sql</FullPath>
243243
</FileNode>
244+
<FileNode Name="SQL Server 2012 Diagnostic Information Queries.sql">
245+
<AssociatedConnectionMoniker />
246+
<AssociatedConnSrvName />
247+
<AssociatedConnUserName />
248+
<FullPath>SQL Server 2012 Diagnostic Information Queries.sql</FullPath>
249+
</FileNode>
250+
<FileNode Name="SQL Server 2014 Diagnostic Information Queries.sql">
251+
<AssociatedConnectionMoniker />
252+
<AssociatedConnSrvName />
253+
<AssociatedConnUserName />
254+
<FullPath>SQL Server 2014 Diagnostic Information Queries.sql</FullPath>
255+
</FileNode>
256+
<FileNode Name="SQL Server 2016 Diagnostic Information Queries.sql">
257+
<AssociatedConnectionMoniker />
258+
<AssociatedConnSrvName />
259+
<AssociatedConnUserName />
260+
<FullPath>SQL Server 2016 Diagnostic Information Queries.sql</FullPath>
261+
</FileNode>
262+
<FileNode Name="SQL Server 2017 Diagnostic Information Queries.sql">
263+
<AssociatedConnectionMoniker />
264+
<AssociatedConnSrvName />
265+
<AssociatedConnUserName />
266+
<FullPath>SQL Server 2017 Diagnostic Information Queries.sql</FullPath>
267+
</FileNode>
244268
<FileNode Name="Vw_WhoIsActive_Blocking.sql">
245269
<AssociatedConnectionMoniker>8c91a03d-f9b4-46c0-a305-b5dcc79ff907:tul1cipcnpdb1:True</AssociatedConnectionMoniker>
246270
<AssociatedConnSrvName>tul1cipcnpdb1</AssociatedConnSrvName>

BlitzQueries/Perf Counters.sql

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ OPTION (RECOMPILE);
2828

2929

3030
--Total amount of RAM consumed by database data (Buffer Pool). This should be the highest usage of Memory on the server.
31-
Select SQLBufferPoolUsedMemoryMB = (Select SUM(pages_kb)/1024 AS [SPA Mem, Mb] FROM sys.dm_os_memory_clerks WITH (NOLOCK) Where type = 'MEMORYCLERK_SQLBUFFERPOOL')
31+
Select SQLBufferPoolUsedMemoryMB = (Select SUM(single_pages_kb+multi_pages_kb)/1024 AS [SPA Mem, Mb] FROM sys.dm_os_memory_clerks WITH (NOLOCK) Where type = 'MEMORYCLERK_SQLBUFFERPOOL')
3232
--Total amount of RAM used by SQL Server memory clerks (includes Buffer Pool)
33-
, SQLAllMemoryClerksUsedMemoryMB = (Select SUM(pages_kb)/1024 AS [SPA Mem, Mb] FROM sys.dm_os_memory_clerks WITH (NOLOCK))
33+
, SQLAllMemoryClerksUsedMemoryMB = (Select SUM(single_pages_kb+multi_pages_kb)/1024 AS [SPA Mem, Mb] FROM sys.dm_os_memory_clerks WITH (NOLOCK))
3434
--How long in seconds since data was removed from the Buffer Pool, to be replaced with data from disk. (Key indicator of memory pressure when below 300 consistently)
3535
,[PageLifeExpectancy] = (SELECT cntr_value FROM sys.dm_os_performance_counters WITH (NOLOCK) WHERE [object_name] LIKE N'%Buffer Manager%' AND counter_name = N'Page life expectancy' )
3636
--How many memory operations are Pending (should always be 0, anything above 0 for extended periods of time is a very high sign of memory pressure)

BlitzQueries/SQL Server 2012 Diagnostic Information Queries.sql

+1,756
Large diffs are not rendered by default.

BlitzQueries/SQL Server 2014 Diagnostic Information Queries.sql

+1,845
Large diffs are not rendered by default.

BlitzQueries/SQL Server 2016 Diagnostic Information Queries.sql

+1,968
Large diffs are not rendered by default.

BlitzQueries/SQL Server 2017 Diagnostic Information Queries.sql

+2,020
Large diffs are not rendered by default.

BlitzQueries/whoIsActive.sql

+17
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,21 @@ select * from sys.dm_os_tasks as t
4646

4747
/*
4848
https://www.brentozar.com/archive/2014/11/many-cpus-parallel-query-using-sql-server/
49+
*/
50+
51+
/*
52+
SELECT top 10 [srvName] = @@servername, DENSE_RANK()OVER(ORDER BY collection_Time ASC) AS CollectionBatch, [collection_time], [TimeInMinutes], [dd hh:mm:ss.mss], [session_id], [sql_text], [sql_command], [login_name],
53+
[wait_info], [tasks], [tran_log_writes], [CPU], [tempdb_allocations], [tempdb_current], [blocking_session_id],
54+
[blocked_session_count], [reads], [writes], [context_switches], [physical_io], [physical_reads], [query_plan], [locks],
55+
[used_memory], [status], [tran_start_time], [open_tran_count], [percent_complete], [host_name], [database_name], [program_name],
56+
[additional_info], [start_time], [login_time], [request_id]
57+
--sql_handle = additional_info.value('(/additional_info/sql_handle)[1]','varchar(500)'),
58+
,query_hash = query_plan.value('(/ShowPlanXML/BatchSequence/Batch/Statements/StmtSimple/@QueryHash)[1]', 'varchar(500)')
59+
,query_plan_hash = query_plan.value('(/ShowPlanXML/BatchSequence/Batch/Statements/StmtSimple/@QueryPlanHash)[1]', 'varchar(500)')
60+
FROM [DBA].[dbo].WhoIsActive_ResultSets AS r
61+
WHERE (CASE WHEN REPLACE(REPLACE(TRY_CONVERT(varchar(max),r.sql_text),char(10),''),char(13),'') like '%INSERT INTO DBO.![DELTA!_Music!_%' ESCAPE '!' THEN 1 ELSE 0 END) = 1
62+
AND (CASE WHEN REPLACE(REPLACE(TRY_CONVERT(varchar(max),r.sql_text),char(10),''),char(13),'') like '%SELECT N.![ReleaseID!], N.![AlbumID!], N.![MediaFormatAttributeID!], N.![ProductFormAttributeID!]%' ESCAPE '!' THEN 1 ELSE 0 END) = 1
63+
--AND [database_name] LIKE 'RoviMusicShipping_UK_%'
64+
ORDER BY [TimeInMinutes] desc
65+
GO
4966
*/

Misscellaneous Queries/Misscellaneous Queries.ssmssqlproj

+2-2
Original file line numberDiff line numberDiff line change
@@ -320,8 +320,8 @@
320320
<FullPath>System Memory Usage.sql</FullPath>
321321
</FileNode>
322322
<FileNode Name="TableSizeMetrics - RecordCount n PageCount.sql">
323-
<AssociatedConnectionMoniker />
324-
<AssociatedConnSrvName />
323+
<AssociatedConnectionMoniker>8c91a03d-f9b4-46c0-a305-b5dcc79ff907:(local):True</AssociatedConnectionMoniker>
324+
<AssociatedConnSrvName>(local)</AssociatedConnSrvName>
325325
<AssociatedConnUserName />
326326
<FullPath>TableSizeMetrics - RecordCount n PageCount.sql</FullPath>
327327
</FileNode>
+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
USE MSDB
2+
GO
3+
4+
SET NOCOUNT ON;
5+
6+
DECLARE @varDate DATETIME
7+
-- Set date to 30 days ago
8+
SET @varDate = DATEADD(d,-7,GETDATE());
9+
10+
DECLARE @r INT;
11+
12+
SET @r = 1;
13+
14+
WHILE @r > 0
15+
BEGIN
16+
BEGIN TRANSACTION;
17+
18+
-- delete from sysmail_attachments
19+
DELETE TOP (10000) FROM dbo.sysmail_attachments
20+
WHERE Last_mod_date < @varDate;
21+
22+
SET @r = @@ROWCOUNT;
23+
24+
COMMIT TRANSACTION;
25+
26+
CHECKPOINT; -- if simple
27+
-- BACKUP LOG ... -- if full
28+
END
29+
GO

Space Issues/Space Issues.ssmssqlproj

+18
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,18 @@
1515
<ConnectionProtocol>NotSpecified</ConnectionProtocol>
1616
<ApplicationName>Microsoft SQL Server Management Studio - Query</ApplicationName>
1717
</ConnectionNode>
18+
<ConnectionNode Name="TUL1CIPCWRDB1:CORPORATE\adwivedi">
19+
<Created>2019-08-20T10:25:05.3509403+05:30</Created>
20+
<Type>SQL</Type>
21+
<Server>TUL1CIPCWRDB1</Server>
22+
<UserName />
23+
<Authentication>Windows Authentication</Authentication>
24+
<InitialDB>DBA</InitialDB>
25+
<LoginTimeout>30</LoginTimeout>
26+
<ExecutionTimeout>0</ExecutionTimeout>
27+
<ConnectionProtocol>NotSpecified</ConnectionProtocol>
28+
<ApplicationName>Microsoft SQL Server Management Studio - Query</ApplicationName>
29+
</ConnectionNode>
1830
<ConnectionNode Name="TUL1CIPEDB2:CORPORATE\adwivedi">
1931
<Created>2019-02-16T23:40:02.0690562+05:30</Created>
2032
<Type>SQL</Type>
@@ -67,6 +79,12 @@
6779
<AssociatedConnUserName />
6880
<FullPath>Ola Log Backup.sql</FullPath>
6981
</FileNode>
82+
<FileNode Name="Purge-Records-In-Chunks.sql">
83+
<AssociatedConnectionMoniker>8c91a03d-f9b4-46c0-a305-b5dcc79ff907:TUL1CIPCWRDB1:True</AssociatedConnectionMoniker>
84+
<AssociatedConnSrvName>TUL1CIPCWRDB1</AssociatedConnSrvName>
85+
<AssociatedConnUserName />
86+
<FullPath>Purge-Records-In-Chunks.sql</FullPath>
87+
</FileNode>
7088
<FileNode Name="Shrink Log Files.sql">
7189
<AssociatedConnectionMoniker>8c91a03d-f9b4-46c0-a305-b5dcc79ff907:TUL1CIPEDB2:True</AssociatedConnectionMoniker>
7290
<AssociatedConnSrvName>TUL1CIPEDB2</AssociatedConnSrvName>

0 commit comments

Comments
 (0)