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 > Default value performance

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-06-08, 10:49
ramesh jampala ramesh jampala is offline
Registered User
 
Join Date: Mar 2007
Posts: 15
Default value performance

Hi,
In DB2 on Z/OS, suppose i have a following Table...
Create Table TB1(col1 char(10) not null, col2 char(10) not null with default 'SAM')......

while inserting the records, if i do not have any value for column col2, which of the following performs better...

1. Insert the record by just providing col1 value. As i am not providing any value col2, DB2 determines the default value for col2 and inserts as 'SAM' for col2.

2.Since i am aware of default value for col2, i can write as
insert into tb1 values('WELLS','SAM')...In this case db2 do not require to determine the default value for col2.

Which of the above two options provides good performance of insert in heavy batch insert programs. I think it is the second option.

Can somebody validate the same....

Thanks
Ramesh
Reply With Quote
  #2 (permalink)  
Old 11-06-08, 15:29
Peter.Vanroose Peter.Vanroose is offline
Registered User
 
Join Date: Sep 2004
Location: Belgium
Posts: 1,079
Most likely the first approach (insert the record by just providing col1 value) performs better since (1) it requires less data traffic from application to DB2, and (2) it requires less data access (reading the passed value) by DB2: DB2 just needs to read the default value once in order to insert it lots of times.
__________________
--_Peter Vanroose,
__IBM Certified Database Administrator, DB2 9 for z/OS
__IBM Certified Application Developer
__ABIS Training and Consulting
__http://www.abis.be/
Reply With Quote
  #3 (permalink)  
Old 11-09-08, 16:16
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
I would drive something like that not through the applications simply for semantical reasons. How would your application know that the default is 'SAM'? The only way is to read the default from the system catalog tables. And in order to make sure things won't become inconsistent if someone does an ALTER TABLE, you will have to read the default value in each transaction again. That's a lot of overhead for no real value as Peter explained.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
  #4 (permalink)  
Old 11-09-08, 16:27
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
You are worrying about something that is trivial. The difference is probably not measureable.
__________________
M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390
Reply With Quote
  #5 (permalink)  
Old 11-09-08, 22:32
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
I did run a test, actually. I don't have a Z/OS system to play with, but on a Windows box with a local connection 1 million inserts that don't provide the default value consistently execute about 1% faster. It is measurable, but performance would not be the main reason if I were to make a decision.
Reply With Quote
  #6 (permalink)  
Old 11-10-08, 00:56
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
So if an insert normally takes .005 seconds, it would take 0.00505 seconds instead (about 1 % difference).
__________________
M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390
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