If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > UDF performance issues.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-01-08, 14:57
ramesh_v_s ramesh_v_s is offline
Registered User
 
Join Date: Jun 2008
Posts: 7
UDF performance issues.

Hi All,

I am trying to use a UDF for DB2. It is a simple UDF written in C++ which takes 2 strings as input concates them and the result is given as output. I am trying this to measure the performance. My fucntion is defined as

CREATE FUNCTION
CPPUDF(
VARCHAR(40) CCSID EBCDIC,
VARCHAR(40) CCSID EBCDIC,
VARCHAR(40) CCSID EBCDIC )
RETURNS
VARCHAR(80) CCSID EBCDIC
LANGUAGE C
PARAMETER VARCHAR NULTERM
NOT DETERMINISTIC
NO SQL
EXTERNAL NAME CPPUDF
PARAMETER STYLE DB2SQL
PROGRAM TYPE SUB
SCRATCHPAD
FINAL CALL
SECURITY USER
WLM ENVIRONMENT DB9GENV3;

I am invoking the above fuction in a COBOL program and the program just has one select statement with this UDF.

The WLM environment is
//DB9GWLM3 PROC DB2SSN=DB9G,NUMTCB=60,APPLENV=DB9GENV3
//*
//NUMTCB@1 SET NUMTCB=
//*
//DSNTPSMP EXEC PGM=DSNX9WLM,TIME=1440,
// PARM='&DB2SSN,20,&APPLENV',
// REGION=0M,DYNAMNBR=5
//* Include SDSNEXIT to use Secondary Authids (DSN3@AT
//STEPLIB DD DISP=SHR,DSN=DSN910.DB9G****NLIB.LOAD

Now I am getting very poor performance with this UDF something like 300 seconds for 10000 iterations of the select statement.

I tried several options but none of them seem to help. Can anyone please throw some light on anything similar they have done or anyhelp in this respect would be highly appreciated.

Thanks a lot in anticipation
Ramesh.
Reply With Quote
  #2 (permalink)  
Old 10-01-08, 18:26
dav1mo dav1mo is offline
Registered User
 
Join Date: Dec 2007
Location: Richmond, VA
Posts: 782
first off why would you need a udf to concatenate the strings? You could just do that in any select statement like:
select :mystrng1 || :mystrng2 || mystrng3, other_cols
from my_table
where ..........

Also, how many seconds does it take to run 10000 iterations of your select without the UDF? What exactly are you doing within your C++? How long does it take to execute it outside of the UDF?

Dave
Reply With Quote
  #3 (permalink)  
Old 10-02-08, 09:40
ramesh_v_s ramesh_v_s is offline
Registered User
 
Join Date: Jun 2008
Posts: 7
Thanks for the response Dave,

Actually concatenating the strings is not the purpose if my UDF. I was soing some complex calculations earlier for which there are no Db2 supported functions. When I saw a very poor performance I wrote this concatenating strings UDF's which basically uses STRCAT function. Outside the UDF it performs like 1 sec for 10000 transactions. When I use the UDF too if I dont use the security USER I get good performance like 2.5 secs for performance but as and when I use Security USER .. I guess WLM estaablishing a RACF security environment is taking all the time. Am not a DBA and not getting a lot of DBA support is really puzzling me what needs to be done.

Thanks
Ramesh.
Reply With Quote
  #4 (permalink)  
Old 10-04-08, 06:41
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
How are you invoking the UDF? I'd say that the authentication should be done only once on the FIRST call made to the function - assuming you have the 10000 UDF calls in the same SQL statement.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
  #5 (permalink)  
Old 10-06-08, 08:56
ramesh_v_s ramesh_v_s is offline
Registered User
 
Join Date: Jun 2008
Posts: 7
Thanks for the response.

Can you please give me a little detail on how do we check authentication in the first call and not in subsequent calls because when I specify security user DB2 is creating a security environment which is causing a big performance hit. The other thing I am looking at is the LE enclaves we are getting. I wonder if IBM had any documented performance stats so that atleast I know I am getting similar to what they have published.

Thanks
Ramesh.
Reply With Quote
  #6 (permalink)  
Old 10-06-08, 08:57
ramesh_v_s ramesh_v_s is offline
Registered User
 
Join Date: Jun 2008
Posts: 7
Sorry,

I forgot to mention that I am invoking the UDF from my COBOL program. I have it as a SELECT X(..,..,..) from SYSIBM.SYSDUMMY1 where X is my UDF.

Thanks
Ramesh.
Reply With Quote
  #7 (permalink)  
Old 10-13-08, 07:30
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
You are calling the UDF in a query against SYSIBM.SYSDUMMY1? If so, then each invocation of the UDF is independent of any other, so the authentication has to be done again and again. Could you run your UDF against some table that processes the data and, thus, pipe lots of data through the UDF instead of making single calls?
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
  #8 (permalink)  
Old 10-15-08, 15:30
ramesh_v_s ramesh_v_s is offline
Registered User
 
Join Date: Jun 2008
Posts: 7
Hi Stolze,

I am getting a getting a better performance when I am running it against a table and the info in the table but at the same time I am trying to acheive a better performance with individual calls and am not able to get any further in that.

Thanks
Ramesh.
Reply With Quote
  #9 (permalink)  
Old 10-15-08, 16:46
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
What do you expect? The UDF is loaded into your WLM environment when called for the first time. The regular z/OS security checks apply there, of course. If your UDF just does a single evaluation, it is unloaded after that (maybe cached, but still...) You can reap a real benefit only if you stream lots of data through the function, i.e. call it on a set of rows. In this respect, it doesn't even make a difference whether we talk about DB2 z/OS and DB2 LUW. Processing single rows is just a stupid way to work with a DBMS (and UDFs are part of that).
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On