PL/SQL

March 8, 2007

XMLELEMENT performance problem (PL/SQL)

Filed under: example, PL/SQL, pl/sql code, XMLELEMENT — Michael Moore @ 10:03 pm

-- 22 seconds on 9i, 2 seconds on 10g
-- Also, a weird thing is that speed does not decrease in a linear  way
 with the number of --iterations. Instead, speed seems to decrease exponentially.
 If you increase the iterations from --200 to 400 , 
the timing goes from 2 seconds to 9.2 seconds.

SET timing on

DECLARE
   x            INTEGER           := 0;
   audit_info   VARCHAR2 ( 2000 );
BEGIN
   WHILE x < 300
       LOOP
             SELECT
                XMLELEMENT ( "DEALER_SERVICE_KEY", '234234' )
             || XMLELEMENT ( "PARENT_KEY", '234234' )
             || XMLELEMENT ( "CAP_TOTAL_KEY", '234234' )
             || XMLELEMENT ( "CAP_ENTITY", '234234' )
             || XMLELEMENT ( "CAP_LAST_RESET_DATE", '234234' )
             || XMLELEMENT ( "CAP_LIMIT", '234234' )
             || XMLELEMENT ( "CURRENT_CNT", '234234' )
             || XMLELEMENT ( "DATE", sysdate)
             || XMLELEMENT ( "CAP_PROFILE2TX_CAP_PROFILE", '234234' )
             || XMLELEMENT ( "WHERE_CLAUSE", '234234' )
             || XMLELEMENT ( "PRODUCT2TX_PRODUCT", '234234' )
             || XMLELEMENT ( "PRODUCT_KEY", '234234' )
             || XMLELEMENT ( "PRODUCT_NAME", '234234' )
             || XMLELEMENT ( "RATE", '234234' )
             || XMLELEMENT ( "GL_NUMBER", '234234' )
             || XMLELEMENT ( "AP_NUMBER", '234234' )
             || XMLELEMENT ( "COMMISSIONS_NUMBER", '234234' )
             || XMLELEMENT ( "INVOICE_STATUS", 'NOTPROCESSED' )
             || XMLELEMENT ( "INVOICE_STATUS_DATE", sysdate)
        INTO audit_info
        FROM DUAL;

      x := x + 1;
   END LOOP;

END;
Advertisements

3 Comments »

  1. Hey..Is this problem resolved. I’m facing the same issue.

    Comment by jithin — September 9, 2008 @ 5:13 am

  2. I don’t know if it was ever resolved. I switched my code to use standard string concatenation and not XMLELEMENT. If you go this route, make sure that your data does not contain and special characters such as “”. XMLELEMENT will escaped these character for you. Obviously, standard string concatenation will not.

    Comment by mike — September 9, 2008 @ 4:58 pm

  3. I think, you should use XMLCONCAT instead of string concatenation of the xml elements. I tried it on an oralce 9i and it finished in 00:00:01.01 instead of about 00:00:30.00. You might need getclobval() to fetch the result into a varchar2.

    Comment by mal-2 — February 8, 2009 @ 3:30 pm


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at WordPress.com.

%d bloggers like this: