Statistiky spuštění reportů

V databázi report serveru je užitečný pohled ExecutionLog3. Umožňuje získat informace o spouštění reportů, o tom, kteří uživatelé reporty spouští a s jakými parametry, jak dlouho trvalo načtení dat, jestli report nezhavaroval atd.

USE ReportServer

SELECT * FROM ExecutionLog3

--nejcasteji spoustene reporty
SELECT ItemPath, COUNT(*) pocetSpusteni 
FROM ExecutionLog3 
WHERE ItemAction = 'Render'
GROUP BY ItemPath 
ORDER BY pocetSpusteni DESC

--nejaktivnejsi uzivatele
SELECT UserName, COUNT(*) pocetSpusteni 
FROM ExecutionLog3 
WHERE ItemAction = 'Render'
GROUP BY UserName
ORDER BY pocetSpusteni DESC

--nejaktivnejsi uzivatele podle reportu
SELECT ItemPath, UserName, COUNT(*) pocetSpusteni 
FROM ExecutionLog3 
WHERE ItemAction = 'Render'
GROUP BY ItemPath, UserName
ORDER BY ItemPath, pocetSpusteni DESC

--reporty s chybou
SELECT ItemPath, UserName, TimeStart
FROM ExecutionLog3 
WHERE Status <> 'rsSuccess'
ORDER BY TimeStart DESC

--reporty s dlouhym nacitanim dat
SELECT ItemPath, UserName, TimeStart,TimeDataRetrieval
FROM ExecutionLog3 
WHERE ItemAction = 'Render'
ORDER BY TimeDataRetrieval DESC

--parametry spusteni
;WITH parametry(ItemPath, UserName, TimeStart, parametry) AS (
	SELECT ItemPath, UserName, TimeStart, CAST('<root><parametr><nazev>'+REPLACE(REPLACE(CAST([Parameters] AS VARCHAR(MAX)),'=','</nazev><hodnota>'),'&','</hodnota></parametr><parametr><nazev>')+'</hodnota></parametr></root>' AS XML) parametry
	FROM ExecutionLog3 
	WHERE ItemAction = 'Render' AND ISNULL(CAST([Parameters] AS NVARCHAR(MAX)),'') <> '' 
)
SELECT ItemPath, 
	UserName, 
	TimeStart, 
	T.p.value('nazev[1]','VARCHAR(50)') parametr, 
	T.p.value('hodnota[1]','VARCHAR(50)') hodnota
FROM parametry
CROSS APPLY parametry.nodes('/root/parametr') AS T(p)