RE: looking for thoughts/advice on AWR_REPORT_HTML and UTL_SMTP

  • From: Administrator User <jonathan@xxxxxxxxxxxxxxxxxx>
  • To: "Christopher.Taylor2@xxxxxxxxxxxx" <Christopher.Taylor2@xxxxxxxxxxxx>, "oracle-l@xxxxxxxxxxxxx" <oracle-l@xxxxxxxxxxxxx>
  • Date: Fri, 5 Oct 2012 06:06:43 +0000

You didn't say which version of Oracle, and that could be relevant.

I ran your select statement from SQL*Plus, and then called your procedure from 
SQL*Plus. In 11.1.0.7 the change in "db block gets" (to pick just one of the 
more obvious stats) was dramatic, so it's possible that there's some feature of 
the simple concatenation of LOBs that makes a difference.

I wrote something about a similar anomaly a few years ago, although the 
strategy for improvement doesn't help:
http://jonathanlewis.wordpress.com/2009/07/09/concatenating-lobs/

You might try explicit use of dbms_lob.create_temporary_lob (with the cache 
attribute) and dbms_lob.wrte_append() in case it makes a difference - but I 
suspect that's what your code is doing under the covers anyway.

Regards
Jonathan Lewis





________________________________________
From: oracle-l-bounce@xxxxxxxxxxxxx [oracle-l-bounce@xxxxxxxxxxxxx] on behalf 
of Christopher.Taylor2@xxxxxxxxxxxx [Christopher.Taylor2@xxxxxxxxxxxx]
Sent: 04 October 2012 21:04
To: oracle-l@xxxxxxxxxxxxx
Subject: looking for thoughts/advice on AWR_REPORT_HTML and UTL_SMTP

I figured out how to send attachments using UTL_SMTP (from code found on the 
web) and the code I'm using uses a clob variable to build the attachment.
So I pieced together a function to build a clob from 
DBMS_WORKLOAD_REPOSITORY.AWR_REPORT_HTML and call that function from my mail 
procedure.

This works surprisingly well to email me a daily AWR report (for a specific 
window of time - nightly batch cycle) *yet* the performance is slow to build 
the clob.

I had looked for a way to read the AWR_REPORT_HTML results directly into an 
attachment but I couldn't figure it out (being very non-proficient in pl/sql) 
so I was wondering if there was a better way to do this?  (To capture the 
results of AWR_REPORT_HTML and mail them as an attachment).

I was thinking I should probably use a bulk collect here perhaps?  Or am I 
overthinking this?

Here's my clob function (just for proof of concept):


CREATE OR REPLACE FUNCTION html_clob
   RETURN CLOB
IS
   p_attach_clob   CLOB := NULL;

   CURSOR c1
   IS
      SELECT
             output
      FROM
             TABLE (sys.DBMS_WORKLOAD_REPOSITORY.awr_report_html (99999999,
                                                                  1,
                                                                  20003,
                                                                  20011));
BEGIN
   FOR rec IN c1
   LOOP
      p_attach_clob := p_attach_clob ||chr(13)||chr(10)|| rec.output;
   END LOOP;

   RETURN p_attach_clob;
END;
/

--
//www.freelists.org/webpage/oracle-l--
//www.freelists.org/webpage/oracle-l


Other related posts: