473,382 Members | 1,225 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Identity Column slow down the insert

I have 2 same windows machine, same instance configure and Database ,
all run DB2 UDB V8.1.5

Test 1 :
create table OUT_1 (LINE VARCHAR(350), LINENUMBER INTEGER NOT NULL
GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1, NO CACHE));
insert into out_1 (line) values
('C000000002XYTNF102020201855000000075000519600040 547000003256510
0000000000000000000000000SIM CAR ADJ JOHN, SMITHJA
CPRM SIM CARMBCORL XYTNF1020282726
00041020206900381468
00000000000');

On machine A, db2batch give the reslut of insert 0.066 second
On machine B, db2batch give the result of insert 0.001 second
If no Identity column
Test ddl_2 :
create table OUT_1 (LINE VARCHAR(350));
insert into out_1 (line) values
('C000000002XYTNF102020201855000000075000519600040 547000003256510
0000000000000000000000000SIM CAR ADJ JOHN, SMITHJA
CPRM SIM CARMBCORL XYTNF1020282726
00041020206900381468
00000000000');
2 Machine give the same result of insert 0.001 second

Test ddl_3 :
create table OUT_1 (LINE VARCHAR(350), LINENUMBER INTEGER NOT NULL
GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1, CACHE
200));
CARert into out_1 (line) values
('C000000002XYTNF102020201855000000075000519600040 547000003256510
0000000000000000000000000SIM CAR ADJ JOHN, SMITHJA
CPRM SIM CARMBCORL XYTNF1020282726
00041020206900381468
00000000000');
2 Machine give the same reulst of insert 0.001 second

My question is what is the secret of GENERATED NO CACHE, why takes 50
times longer?
Thanks

Feb 3 '06 #1
8 4286
sh*******@gmail.com wrote:
I have 2 same windows machine, same instance configure and Database ,
all run DB2 UDB V8.1.5

Test 1 :
create table OUT_1 (LINE VARCHAR(350), LINENUMBER INTEGER NOT NULL
GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1, NO CACHE));
insert into out_1 (line) values
('C000000002XYTNF102020201855000000075000519600040 547000003256510
0000000000000000000000000SIM CAR ADJ JOHN, SMITHJA
CPRM SIM CARMBCORL XYTNF1020282726
00041020206900381468
00000000000');

On machine A, db2batch give the reslut of insert 0.066 second
On machine B, db2batch give the result of insert 0.001 second
If no Identity column
Test ddl_2 :
create table OUT_1 (LINE VARCHAR(350));
insert into out_1 (line) values
('C000000002XYTNF102020201855000000075000519600040 547000003256510
0000000000000000000000000SIM CAR ADJ JOHN, SMITHJA
CPRM SIM CARMBCORL XYTNF1020282726
00041020206900381468
00000000000');
2 Machine give the same result of insert 0.001 second

Test ddl_3 :
create table OUT_1 (LINE VARCHAR(350), LINENUMBER INTEGER NOT NULL
GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1, CACHE
200));
CARert into out_1 (line) values
('C000000002XYTNF102020201855000000075000519600040 547000003256510
0000000000000000000000000SIM CAR ADJ JOHN, SMITHJA
CPRM SIM CARMBCORL XYTNF1020282726
00041020206900381468
00000000000');
2 Machine give the same reulst of insert 0.001 second

My question is what is the secret of GENERATED NO CACHE, why takes 50
times longer?
Thanks

Evreey time DB2 has to load a cache (which with NOCACHE means always)
DB2 needs to update the LASTASSIGNVAL column in SYSIBM.SYSSEQUENCES.
Also DB2 needs to write a log record for forward logging.
You should have very special circumstances that require the use of
NOCACHE... what are they?

Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
DB2 UDB for Linux, Unix, Windows
IBM Toronto Lab
Feb 3 '06 #2
It is a temp table used in one job (create when job start and drop
after finish).
This job run fine in machine B and machine A for years, but very slow
in machine A suddenly.
I get this "NO CACHE" DDL from dynamic sql snapshot, found the insert
is the most time comsuing sql.

Feb 3 '06 #3
sh*******@gmail.com wrote:
It is a temp table used in one job (create when job start and drop
after finish).
This job run fine in machine B and machine A for years, but very slow
in machine A suddenly.
I get this "NO CACHE" DDL from dynamic sql snapshot, found the insert
is the most time comsuing sql.

If it's a temp table there is really no reason for NOCACHE.
Also could it be the temp table is declared as LOGGED?
Did someone change the USER TEMPORARY TABLESPACE (SMS vs DMS), hot
tablespace, ...

Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
DB2 UDB for Linux, Unix, Windows
IBM Toronto Lab
Feb 3 '06 #4
It is not GLOBAL TEMP table defined by "DECLARE GLOBAL TEMPORARY
TABLE", it is a temp REGULAR table created within a job by "create
table OUT_1 (LINE VARCHAR(350), LINENUMBER INTEGER NOT NULL
GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1, NO
CACHE));", use regular tablespace.
I could not find the reason the insert slow down suddenly.

Feb 3 '06 #5
sh*******@gmail.com wrote:
It is not GLOBAL TEMP table defined by "DECLARE GLOBAL TEMPORARY
TABLE", it is a temp REGULAR table created within a job by "create
table OUT_1 (LINE VARCHAR(350), LINENUMBER INTEGER NOT NULL
GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1, NO
CACHE));", use regular tablespace.
I could not find the reason the insert slow down suddenly.

How did you arrive at this statement? Purely by elapsed time?
Take a look at the basics. Do you have an I/O bottleneck?
Is it limitted to this tablespace? ...

If I were you I'd remove the NOCACHE
(on V8.2 it's just an ALTER TABLE ALTER COLUMN statement, online)
That will exclude the idnetity column as culprit right there.

Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
DB2 UDB for Linux, Unix, Windows
IBM Toronto Lab
Feb 3 '06 #6
I get this statement from the dynamic sql snapshot, found this insert
has the longest execution time.
And make the sript above accordingly, benchmarked using db2batch and
proved the "No Cache" identity slow down the insert.
Have told the developer to optimize the code to use cache 500, but why
slow down suddenly for this "No Cache" insert but other insert with
"Cache" is still OK.
If there are bottleneck on this tbs, how come it doesnot affect other
insert. The "No Cache" identity insert take 50 times more than general
insert.

Feb 3 '06 #7
sh*******@gmail.com wrote:
I get this statement from the dynamic sql snapshot, found this insert
has the longest execution time.
And make the sript above accordingly, benchmarked using db2batch and
proved the "No Cache" identity slow down the insert.
Have told the developer to optimize the code to use cache 500, but why
slow down suddenly for this "No Cache" insert but other insert with
"Cache" is still OK. You mean "NOCACHE" right? If there are bottleneck on this tbs, how come it doesnot affect other
insert. The "No Cache" identity insert take 50 times more than general
insert.

Other insert against the same table? When is thsi other insert run?
Eg. you could run into a concurrency issue. Possibly you're waiting on a
lock...? There are many possibilities, but to understand requires more
than simply staring at teh individual statement.

Cheers
Serge

--
Serge Rielau
DB2 Solutions Development
DB2 UDB for Linux, Unix, Windows
IBM Toronto Lab
Feb 3 '06 #8
Ian
sh*******@gmail.com wrote:
I get this statement from the dynamic sql snapshot, found this insert
has the longest execution time.
And make the sript above accordingly, benchmarked using db2batch and
proved the "No Cache" identity slow down the insert.
Have told the developer to optimize the code to use cache 500, but why
slow down suddenly for this "No Cache" insert but other insert with
"Cache" is still OK.


Serge answered that already.

Adding the NOCACHE option to an identity means that every single
insert into the table will ALSO require a write to SYSIBM.SYSSEQUENCES
and the corresponding logging.

When DB2 caches the identity column values, they are held in memory;
thus you only incur the overhead of writing to SYSIBM.SYSSEQUENCES
every N inserts (where N = the size of the cache).
Feb 6 '06 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Rathtap | last post by:
I want to use the Identity field (increment 1,1) as a primary key and have a unique constraint on my other field which is of type char. I am worried that related data in other tables may lose...
5
by: grzes | last post by:
MS SQL Server 2000. My case is: I have the table T with primary key calling __recid int without identity property. This table includes a lot of records (about 1000000). I need to convert __recid's...
2
by: Devesh Aggarwal | last post by:
Hi, I have a backup and restore module in my project. The backup uses a typed dataset object (XSD) to get the data from database and creates a xml file as the backup file (using the WriteXml...
6
by: Who.Really.Really.Cares | last post by:
Hi! I guess this must be a FAQ but I'll give it a try. I've searched the web and usenet archive and found only negative answers. But most of them were dated like 3-4 years back. Hasn't anything...
2
by: .Net Newbie | last post by:
Hello, I am somewhat new to .Net and currently working on an intranet site using C# going against SQL Server 2k. I am accepting personal information on a single webform and trying to insert the...
5
by: Veeru71 | last post by:
Given a table with an identity column (GENERATED BY DEFAULT AS IDENTITY), is there any way to get the last generated value by DB2 for the identity column? I can't use identity_val_local() as...
15
by: gunnar.sigurjonsson | last post by:
I´m having some problem retrieving identity value from my newly inserted row into a view. I have two tables T1 and T2 which I define as following CREATE TABLE T1 ( id BIGINT GENERATED ALWAYS...
13
by: PinkBishop | last post by:
I am using VS 2005 with a formview control trying to insert a record to my access db. The data is submitted to the main table no problem, but I need to carry the catID to the bridge table...
0
by: Frank Swarbrick | last post by:
So we're trying to decide if it's better to use IDENTITY columns or sequences to create a surrogate key as the primary key for our tables. I kind of like the identity column, because it's more...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.