Real Time SQL Monitoring
March 10, 2011 12 Comments
I’m a sucker for convenience.
I’ve always liked the /*+ GATHER_PLAN_STATISTICS */ hint when followed by
SELECT * FROM TABLE(DBMS_XPLAN.DISPLAY_CURSOR(NULL,NULL,'ALLSTATS LAST'));
Yes, I know you can get the same information via other means but I don’t care, I love it (having regressed to a 9i site for nearly a year and only back to a civilised Oracle version for a couple of weeks, I’m probably guilty of a little overexuberance – it’s not often that can be said about me).
There’s always been a slight conundrum though in that you need to wait for your SQL to complete before you get your execution plan and runtime statistics back.
But, in 11g, wait no more.
You’ve got REAL TIME SQL MONITORING.
It’s cool, it’s convenient. What’s not to like?
I know I’ve been back off 11g for about a year now, but how did I miss this previously?
This is old news – but how come more people don’t use it? (Other than they’re not on 11, of course).
Obviously, there are GUIs and buttons and HTML versions, etc.
Me – I like my command line and text reports
Anyway, just to demo an example.
I’ve pasted the text output of the report into Excel because
- WordPress only allows me upload a small set of filetypes and
- Excel was the only one that could cope nicely with the width (“never mind the quality, feel the width” as they say).
This demo was done at the end of the SQL – i.e. it wasn’t real-time monitoring but if you do it whilst the SQL is running, there’s extra progress information which comes from V$SESSION_LONGOPS – i.e. roughly how far through that HASH JOIN are we?
Also, this statement was run in parallel and it produced a really nice summary of parallel execution details.
SELECT dbms_sqltune.report_sql_monitor('8dwq85mf22bs2') FROM dual;
can produce a report a bit like this