我正在支持偶尔出现性能问题的应用程序。客户想知道页面的播放频率。
即。页面占用的总时间大于x秒/页面请求总数
我想写一个查询来获取所需的数据。
SQL中的这样的东西可能会起作用,但在IIS Log解析器中不起作用。
select URL, count(case when time > 100 then 1 else null end), count(*)
from table1
group by URL
答案 0 :(得分:5)
这里的问题是你需要两个查询。
无论花费多少时间,都要计算每页请求的总数
SELECT cs-uri-stem, COUNT(*) AS all-requests
FROM ex*.log
GROUP BY cs-uri-stem
一个计算时间拍摄的页数> X秒
SELECT cs-uri-stem, COUNT(*) as total-requests
FROM ex*.log
WHERE time-taken > 1000 <- time_taken is milliseconds
GROUP BY cs-uri-stem
您所需的结果需要加入:
SELECT a.cs-uri-stem, COUNT(*) as total-requests, b.all-requests
FROM ex*.log AS a
JOIN (
SELECT cs-uri-stem, COUNT(*) AS all-requests
FROM ex*.log
GROUP BY cs-uri-stem
) AS b ON b.cs-uri-stem = a.cs-uri-stem
WHERE a.time-taken >1000
GROUP BY a.cs-uri-stem
不幸的是,LogParser中没有对JOIN的支持。
您可以做的是将两个查询的结果导入SQL数据库并在那里运行查询:
SELECT a.cs-uri-stem, COUNT(*) as total-requests, b.all-requests
FROM long_running_pages AS a
JOIN all_pages_grouped b ON ( a.cs-uri-stem = b.cs-uri-stem)
GROUP BY a.cs-uri-stem