Generate HTML SQL Monitor Output for a Query Running from the Shard Catalog

To generate an HTML SQL monitor output, you can follow these steps:

  1. Add hint to query:

    SELECT /*+ MONITOR */ ...

    For example, a cross-shard query from the shard catalog:

    select /*+ MONITOR */ count(*) from CUSTOMER;
  2. Get SQL_ID of the query from v$sql.

    SELECT SQL_ID, SQL_FULLTEXT
    FROM V$SQL
    WHERE UPPER(SQL_FULLTEXT) LIKE '%CUSTOMER%'
    AND LAST_ACTIVE_TIME > sysdate -1
    ORDER BY LAST_ACTIVE_TIME DESC;
  3. Generate a report in a file ( for example, report.html in either the default or a specific folder with the same or different name).

    SET LONG 1000000
    SET LONGCHUNKSIZE 1000000
    SET LINESIZE 1000
    SET PAGESIZE 0
    SET TRIM ON
    SET TRIMSPOOL ON
    SET ECHO OFFSET FEEDBACK OFF
    spool report.html
    -- replace sql_id values with sql_id of the query
    SELECT DBMS_SQLTUNE.report_sql_monitor( sql_id => 'dfj5upfq6w50j',
      type => 'ACTIVE', report_level => 'ALL') AS report
    FROM dual;
    spool off;
  4. Find the generated SQL Monitor report and view it in a browser or any HTML viewer tool.