Transient monitoring data

Because monitoring tables contain stateful data, take care when joining or using aggregates in your queries because data may not be available if the plan requires that the table be queried multiple times. For example:

select s.SPID, s.CpuTime, s.LineNumber, t.SQLText
from monProcessStatement s, monProcessSQLText t
where s.SPID=t.SPID
and s.CpuTime = (select max(CpuTime) from monProcessStatement)

Here, the monProcessStatement table is queried twice; first to find the maximum CpuTime, and then to match the maximum. When Adaptive Server performs the second query, there are three potential outcomes returned from monProcessStatement:

When you are designing queries, keep in mind that, because the data contained in them is transient, joins and aggregates may not return the expected results if the plan requires that the table is queried multiple times.