Существуют ли динамические административные представления в SQL Server Express? Попробуйте использовать sys.dm_exec_query_stats, чтобы увидеть, получите ли вы какой-либо результат назад. Если это так, у меня есть несколько хранимых процедур, которые вы можете выполнить для оптимизации производительности. Я привожу вам пример одной из процедур и, если хотите, могу опубликовать некоторые другие.
CREATE PROCEDURE [ADMIN].[spExecutionTimeStats]
@DBName AS SYSNAME
AS
-- +----------------------------------------------------------------------------------------------------------------
-- ! O b j e c t : ADMIN.spExecutionTimeStats
-- ! R e t u r n s : NONE
-- ! P a r a m e t e r s : Name DataType Description
-- + ======================= ============== ==================================================
-- ! @dbname sysname
-- + ---------------------------------------------------------------------------------------------------------------
-- ! O b j e c t i v e :
-- + ---------------------------------------------------------------------------------------------------------------
-- ! S A M P L E S :
-- ! EXEC ADMIN.spExecutionTimeStats 'DWH'
-- ! EXEC ADMIN.spExecutionTimeStats 'DWH_TOOLKIT'
-- ! EXEC ADMIN.spExecutionTimeStats 'DWH_HISTORY'
-- + ---------------------------------------------------------------------------------------------------------------
-- ! H i s t o r y :
-- + ---------------------------------------------------------------------------------------------------------------
-- ! Date Who What
-- + ========== ===== ========================================================================
-- ! 2009-09-04 HAWI Initial version
-- +----------------------------------------------------------------------------------------------------------------
--DECLARE @DBName AS SYSNAME='DWH'
DECLARE @SQL NVARCHAR(MAX)
SET @SQL='SELECT TOP 100 percent
''' +@DBName +'''AS DBName,
OBJECT_SCHEMA_NAME(s.object_id, DB_ID(''' +@DBName +''')) AS Schema_name,
S.name,
D.execution_count,
D.total_physical_reads,
D.total_logical_reads,
d.total_logical_writes,
d.last_execution_time,
total_elapsed_time_s=convert(money,d.total_elapsed_time)/1000000,
max_elapsed_time_s=convert(money,D.max_elapsed_time)/1000000,
last_elapsed_time_s=convert(money,d.last_elapsed_time)/1000000,
min_elapsed_time_s=convert(money,D.min_elapsed_time)/1000000,
avg_time_s=(convert(money,d.total_elapsed_time)/d.execution_count)/1000000,
d.sql_handle as proc_handle,
stmnt.*
FROM ' + @dbname + '.sys.procedures s
INNER JOIN ' + @dbname + '.sys.dm_exec_procedure_stats d
ON s.object_id = d.object_id
LEFT JOIN
(
SELECT TOP 100 PERCENT
QS.sql_handle,
ROW_NUMBER() OVER(PARTITION BY qs.sql_handle ORDER BY statement_start_offset) AS statement_no,
qs.execution_count,
qs.total_physical_reads,
qs.total_logical_reads,
qs.total_logical_writes,
qs.last_execution_time,
sql_total_elapsed_time_s=convert(money,qs.total_elapsed_time)/1000000,
sql_max_elapsed_time_s=convert(money,qs.max_elapsed_time)/1000000,
sql_last_elapsed_time_s=convert(money,qs.last_elapsed_time)/1000000,
sql_min_elapsed_time_s=convert(money,qs.min_elapsed_time)/1000000,
sql_avg_time_s=(convert(money,qs.total_elapsed_time)/qs.execution_count)/1000000,
SUBSTRING(ST.text, (QS.statement_start_offset/2) + 1,
((CASE statement_end_offset
WHEN -1 THEN DATALENGTH(st.text)
ELSE QS.statement_end_offset END
- QS.statement_start_offset)/2) + 1) AS statement_text
FROM ' + @dbname + '.sys.dm_exec_query_stats AS QS
CROSS APPLY ' + @dbname + '.sys.dm_exec_sql_text(QS.sql_handle) as ST
) AS stmnt
ON d.sql_handle=stmnt.sql_handle
WHERE
convert(money,d.total_elapsed_time)/d.execution_count/1000000>10
OR
d.last_elapsed_time > (d.total_elapsed_time/d.execution_count)*1.15
ORDER BY avg_time_s DESC;'
PRINT @SQL;
EXEC sp_executeSQL @SQL;
GO