
Chapter 6. Custom Database Monitor Analysis 195
6.3.3 Using SQL views for the Database Monitor table
When using queries to analyze the Database Monitor table, you can make the queries more
readable by using views. For example, we look at a query that shows table scans, which can
be through a simple view, making it easier to see an overview of the query.
Example 6-10 shows the query before we create a view.
Example 6-10 Query before using an SQL view
WITH tablescans AS (
SELECT qqjfld,qqucnt,qqrest,qqtotr
FROM mydbmon
WHERE qqrid=3000)
SELECT SUM(qqi6) "Total Time (Mics)", COUNT(*) "Times Run",
a.qqucnt, integer(avg(b.qqrest)) "Est Rows Selected" ...