top of page
Search
Kunal Ranpura
Aug 12, 20191 min read
SQL Server Missing Indexes current database by Index Advantage
SELECT user_seeks * avg_total_user_cost * (avg_user_impact * 0.01) AS [index_advantage], migs.last_user_seek, mid.[statement] AS...
17 views0 comments
Kunal Ranpura
Aug 12, 20191 min read
Find your SQL Server Index writes vs reads
-- Possible Bad NC Indexes (writes > reads) SELECT OBJECT_NAME(s.[object_id]) AS [Table Name], i.name AS [Index Name], i.index_id,...
53 views0 comments
Kunal Ranpura
Aug 12, 20191 min read
Lists the top SQL Server statements by average input/output usage for the current database
SELECT TOP(50) OBJECT_NAME(qt.objectid) AS [SP Name], (qs.total_logical_reads + qs.total_logical_writes) /qs.execution_count AS [Avg IO],...
15 views0 comments
Kunal Ranpura
Aug 12, 20191 min read
Top Cached SPs By Total Logical Writes.
-- Logical writes relate to both memory and disk I/O pressure SELECT TOP(25) p.name AS [SP Name], qs.total_logical_writes AS...
8 views0 comments
Kunal Ranpura
Aug 12, 20191 min read
-- Top Cached SPs By Total Physical Reads. Physical reads relate to disk I/O pressure
SELECT TOP(25) p.name AS [SP Name],qs.total_physical_reads AS [TotalPhysicalReads], qs.total_physical_reads/qs.execution_count AS...
7 views0 comments
Kunal Ranpura
Aug 12, 20191 min read
-- Top Cached SQL Server Stored Procedure By Total Logical Reads.
-- Top Cached SPs By Total Logical Reads. Logical reads relate to memory pressure SELECT TOP(25) p.name AS [SP Name],...
10 views0 comments
Kunal Ranpura
Aug 12, 20191 min read
-- Top Cached SPs By Total Worker time. Worker time relates to CPU cost
SELECT TOP(25) p.name AS [SP Name], qs.total_worker_time AS [TotalWorkerTime], qs.total_worker_time/qs.execution_count AS...
8 views0 comments
Kunal Ranpura
Aug 12, 20191 min read
-- Top Cached SPs By Avg Elapsed Time
SELECT TOP(25) p.name AS [SP Name], qs.total_elapsed_time/qs.execution_count AS [avg_elapsed_time], qs.total_elapsed_time,...
8 views0 comments
Kunal Ranpura
Aug 9, 20191 min read
Find Size of all Databases in SQL Instance in GB
SELECT distinct d.name AS 'Database', SUM(m.size * 8/1024000) OVER (PARTITION BY d.name) AS 'Database Total Size GB' FROM...
7 views0 comments
Kunal Ranpura
Jul 30, 20191 min read
Top Cached Stored Procedure by Execution Count
-- Top Cached SPs By Execution Count (SQL 2008) SELECT TOP(250) p.name AS [SP Name], qs.execution_count, --ISNULL(qs.execution_count/DATE...
19 views0 comments
Kunal Ranpura
Jul 30, 20191 min read
Find Your SQL Server Database IO stats by Data and Log Files
-- I/O Statistics by file for the current database SELECT DB_NAME(DB_ID()) AS [Database Name],a.[file_id],b.name as [File_Name],...
7 views0 comments
Kunal Ranpura
Jul 30, 20191 min read
SQL Server Find Transactional Log Size and Used Percentage
-- Get transaction log size and space information for the current database SELECT DB_NAME(database_id) AS [Database Name], database_id,...
17 views0 comments
Kunal Ranpura
Jul 30, 20191 min read
Find Available space and Size of your SQL Server Data and Log Files
-- **** Switch to a user database ***** USE YourDatabaseName; GO -- Individual File Sizes and space available for current database SELECT...
13 views0 comments
Kunal Ranpura
Jul 30, 20191 min read
Find space used in SQL Server Buffer cache by ad-hoc queries
-- Find single-use, ad-hoc queries that are bloating the plan cache SELECT TOP(20) [text] AS [QueryText], cp.size_in_bytes/1024 Size_MB...
70 views0 comments
Kunal Ranpura
Jul 30, 20191 min read
Find SQL Server Memory Clerk Usage
-- Memory Clerk Usage for instance -- Look for high value for CACHESTORE_SQLCP (Ad-hoc query plans) SELECT TOP(10) [type] AS [Memory...
43 views0 comments
Kunal Ranpura
Jul 30, 20191 min read
SQL Server Memory Grants Pending value
-- Memory Grants Pending value for default instance SELECT cntr_value AS [Memory Grants Pending] FROM sys.dm_os_performance_counters WITH...
27 views0 comments
Kunal Ranpura
Jul 30, 20191 min read
Find SQL Server Memory Grant OutStanding
-- Memory Grants Outstanding value for default instance SELECT cntr_value AS [Memory Grants Outstanding] FROM sys.dm_os_performance_count...
86 views0 comments
Kunal Ranpura
Jul 30, 20191 min read
Find SQL Server Page Life Expectancy
-- Page Life Expectancy (PLE) value for default instance SELECT cntr_value AS [Page Life Expectancy] FROM sys.dm_os_performance_counters...
21 views0 comments
Kunal Ranpura
Jul 30, 20191 min read
Check if your SQL Server is under Memory Pressure
-- SQL Server Process Address space info --(shows whether locked pages is enabled, among other things) SELECT physical_memory_in_use_kb/1...
23 views0 comments
Kunal Ranpura
Jul 30, 20191 min read
Find SQL Server Memory total and Available including Page File Size
-- Good basic information about memory amounts and state SELECT total_physical_memory_kb/1024000 Total_Physical_MM_GB,...
22 views0 comments
bottom of page