473,395 Members | 1,937 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,395 software developers and data experts.

Slow prepare times for inserts

TC
I am having an issue where inserts are taking a lot longer than I would
expect. So far it seem that it is just the first insert. (Although, I
have other people telling me it is happening more than just the firs
time) The times for a single insert are anywhere from 2-10 seconds. I
can't imagine what takes that long. We use JDBC and the bulk of this
time is on the prepare of the statment. Does anyone have any ideas on
what could be causing this?

Sep 27 '06 #1
11 1771
TC wrote:
I am having an issue where inserts are taking a lot longer than I would
expect. So far it seem that it is just the first insert. (Although, I
have other people telling me it is happening more than just the firs
time) The times for a single insert are anywhere from 2-10 seconds. I
can't imagine what takes that long. We use JDBC and the bulk of this
time is on the prepare of the statment. Does anyone have any ideas on
what could be causing this?
Does the target table have triggers or RI constraints?
If there are triggers are some of them AFTER o INSTEAD OF triggers which
in turn modify tables with triggers, etc, etc.
A quick look at the plan will show whether the INSERT in simple (just a
few operators in visual explain) or nasty (pages of stuff in explain).

Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab

IOD Conference
http://www.ibm.com/software/data/ond...ness/conf2006/
Sep 27 '06 #2
TC
Serge Rielau wrote:
Does the target table have triggers or RI constraints?
If there are triggers are some of them AFTER o INSTEAD OF triggers which
in turn modify tables with triggers, etc, etc.
A quick look at the plan will show whether the INSERT in simple (just a
few operators in visual explain) or nasty (pages of stuff in explain).
Thanks for your response. We do not have triggers or RI contstraints.
I had just noticed an article that said you could do an explain plan on
inserts. I ran one and it was huge. We did migrate from Oracle so we
have made use of a set of UDFs provided by IBM called the MTK
(Migration Toolkit) These functions emulate equivilent functions that
exist in Oracle. Is it possible that these functions are causing this
issue? I will try to experiment with taking these out and running
another plan. If this is the cause, I am not sure what I am going to
do about it. We rely on these functions pretty heavily.

Sep 28 '06 #3
TC
Serge Rielau wrote:
Does the target table have triggers or RI constraints?
If there are triggers are some of them AFTER o INSTEAD OF triggers which
in turn modify tables with triggers, etc, etc.
A quick look at the plan will show whether the INSERT in simple (just a
few operators in visual explain) or nasty (pages of stuff in explain).
Thanks for your response. We do not have triggers or RI contstraints.
I had just noticed an article that said you could do an explain plan on
inserts. I ran one and it was huge. We did migrate from Oracle so we
have made use of a set of UDFs provided by IBM called the MTK
(Migration Toolkit) These functions emulate equivilent functions that
exist in Oracle. Is it possible that these functions are causing this
issue? I will try to experiment with taking these out and running
another plan. If this is the cause, I am not sure what I am going to
do about it. We rely on these functions pretty heavily.

Sep 28 '06 #4
TC
Serge Rielau wrote:
Does the target table have triggers or RI constraints?
If there are triggers are some of them AFTER o INSTEAD OF triggers which
in turn modify tables with triggers, etc, etc.
A quick look at the plan will show whether the INSERT in simple (just a
few operators in visual explain) or nasty (pages of stuff in explain).
Thanks for your response. We do not have triggers or RI contstraints.
I had just noticed an article that said you could do an explain plan on
inserts. I ran one and it was huge. We did migrate from Oracle so we
have made use of a set of UDFs provided by IBM called the MTK
(Migration Toolkit) These functions emulate equivilent functions that
exist in Oracle. Is it possible that these functions are causing this
issue? I will try to experiment with taking these out and running
another plan. If this is the cause, I am not sure what I am going to
do about it. We rely on these functions pretty heavily.

Sep 28 '06 #5
TC
Serge Rielau wrote:
Does the target table have triggers or RI constraints?
If there are triggers are some of them AFTER o INSTEAD OF triggers which
in turn modify tables with triggers, etc, etc.
A quick look at the plan will show whether the INSERT in simple (just a
few operators in visual explain) or nasty (pages of stuff in explain).
Thanks for your response. We do not have triggers or RI contstraints.
I had just noticed an article that said you could do an explain plan on
inserts. I ran one and it was huge. We did migrate from Oracle so we
have made use of a set of UDFs provided by IBM called the MTK
(Migration Toolkit) These functions emulate equivilent functions that
exist in Oracle. Is it possible that these functions are causing this
issue? I will try to experiment with taking these out and running
another plan. If this is the cause, I am not sure what I am going to
do about it. We rely on these functions pretty heavily.

I just removed the calls to the MTK toolkit and the graph in the
explain plan became very simple.

Sep 28 '06 #6
TC
Serge Rielau wrote:
Does the target table have triggers or RI constraints?
If there are triggers are some of them AFTER o INSTEAD OF triggers which
in turn modify tables with triggers, etc, etc.
A quick look at the plan will show whether the INSERT in simple (just a
few operators in visual explain) or nasty (pages of stuff in explain).
Thanks for your response. We do not have triggers or RI contstraints.
I had just noticed an article that said you could do an explain plan on
inserts. I ran one and it was huge. We did migrate from Oracle so we
have made use of a set of UDFs provided by IBM called the MTK
(Migration Toolkit) These functions emulate equivilent functions that
exist in Oracle. Is it possible that these functions are causing this
issue? I will try to experiment with taking these out and running
another plan. If this is the cause, I am not sure what I am going to
do about it. We rely on these functions pretty heavily.

BTW, I tested it and when I get rid of the MTK function calls the
explain graph gets very simple.

Sep 28 '06 #7
TC
Serge Rielau wrote:
Does the target table have triggers or RI constraints?
If there are triggers are some of them AFTER o INSTEAD OF triggers which
in turn modify tables with triggers, etc, etc.
A quick look at the plan will show whether the INSERT in simple (just a
few operators in visual explain) or nasty (pages of stuff in explain).
Thanks for your response. We do not have triggers or RI contstraints.
I had just noticed an article that said you could do an explain plan on
inserts. I ran one and it was huge. We did migrate from Oracle so we
have made use of a set of UDFs provided by IBM called the MTK
(Migration Toolkit) These functions emulate equivilent functions that
exist in Oracle. Is it possible that these functions are causing this
issue? I will try to experiment with taking these out and running
another plan. If this is the cause, I am not sure what I am going to
do about it. We rely on these functions pretty heavily.

BTW, I tested it and when I get rid of the MTK function calls the
explain graph gets very simple.

Sep 28 '06 #8
TC wrote:
Serge Rielau wrote:
>Does the target table have triggers or RI constraints?
If there are triggers are some of them AFTER o INSTEAD OF triggers which
in turn modify tables with triggers, etc, etc.
A quick look at the plan will show whether the INSERT in simple (just a
few operators in visual explain) or nasty (pages of stuff in explain).

Thanks for your response. We do not have triggers or RI contstraints.
I had just noticed an article that said you could do an explain plan on
inserts. I ran one and it was huge. We did migrate from Oracle so we
have made use of a set of UDFs provided by IBM called the MTK
(Migration Toolkit) These functions emulate equivilent functions that
exist in Oracle. Is it possible that these functions are causing this
issue? I will try to experiment with taking these out and running
another plan. If this is the cause, I am not sure what I am going to
do about it. We rely on these functions pretty heavily.

BTW, I tested it and when I get rid of the MTK function calls the
explain graph gets very simple.
Care to post the INSERT statement.
While ORA8.* SQL UDF will certainly blow up you graph I'm surprised that
teh result is huge unless you have a lot of them. then th eqyestion is: Why?

After you have successfully migrated the function with MTK you need to
take alook at teh slo areas and first decide whether soem emulatiosn of
the MTK are really needed.
E.g. all the code injected by MTK for "emtpy string equals NULL" won't
be needed if you don't use NULLs.
The MTK is very liberally adding ORA8.* functions even if the
differences to DB2 functions are pathological in nature.

Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab

IOD Conference
http://www.ibm.com/software/data/ond...ness/conf2006/
Sep 28 '06 #9

TC wrote:
I am having an issue where inserts are taking a lot longer than I would
expect. So far it seem that it is just the first insert. (Although, I
have other people telling me it is happening more than just the firs
time) The times for a single insert are anywhere from 2-10 seconds. I
can't imagine what takes that long. We use JDBC and the bulk of this
time is on the prepare of the statment. Does anyone have any ideas on
what could be causing this?
By any chance is this the only client attached to the database? And is
the connection made at the begining of this insert? DB2 can shut
itself down if there are no connections made, and will wake up with the
first connection, which takes a bit of time, which could explain this,
I think. If that is so, there are ways to make DB2 stay awake, if you
need to.

-Chris

Sep 28 '06 #10
TC
Care to post the INSERT statement.

insert
into canpck
( cangrp, wh_id, wrkref, wrktyp, schbat,
srcloc, srcare, dstare, ship_line_id, ship_id,
client_id, ordnum, ordlin, ordsln, concod,
cmbcod, lblseq, pckqty, appqty, pcksts,
prtnum, prt_client_id, invsts, lodlvl, untcas,
untpak, ftpcod, visflg, splflg, locflg,
lodflg, subflg, dtlflg, prtflg, orgflg,
revflg, lotflg, qtyflg, adddte, candte,
can_usr_id, cancod, remqty, invsts_prg, frsflg,
min_shelf_hrs, pckdte, catch_qty_flg, pipflg, list_id,
list_seqnum)
values
( 'grp1', 'WMD1', 'TC_22', 'R', NULL,
'x', 'x', 'x', 'x', 'x',
'x', 'x', 'x', 'x', 'x',
'x', 'x', 0, 0, 'x',
'x', 'x', 'x', 'x', 0,
0, 'x', 0, 0, 0,
0, 0, 0, 0, 0,
0, 0, 0, ora.to_date('20060807120000', 'YYYYMMDDHH24MISS'),
ora.to_date('20060807120000', 'YYYYMMDDHH24MISS'),
'x', 'x', 0, 'x', 0,
0, ora.to_date('20060807120000', 'YYYYMMDDHH24MISS'), 0, 0, 'x',
0)
By any chance is this the only client attached to the database? And is
the connection made at the begining of this insert? DB2 can shut
itself down if there are no connections made, and will wake up with the
first connection, which takes a bit of time, which could explain this,
I think. If that is so, there are ways to make DB2 stay awake, if you
need to.
No, I tested this many times by forcing it to recompile by adding a
space character.

Sep 29 '06 #11
TC wrote:
>By any chance is this the only client attached to the database? And is
the connection made at the begining of this insert? DB2 can shut
itself down if there are no connections made, and will wake up with the
first connection, which takes a bit of time, which could explain this,
I think. If that is so, there are ways to make DB2 stay awake, if you
need to.

No, I tested this many times by forcing it to recompile by adding a
space character.
I guess the question was if you disconnect between the insert statements or
if you keep at least one connection alive and, thus, the database
activated.

--
Knut Stolze
DB2 Information Integration Development
IBM Germany
Sep 29 '06 #12

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

Similar topics

5
by: Ken Brubaker | last post by:
Using DB2 8.1 FP5 on Win2000 After creating and configuring a new database, we stop db2 and start it again. We then launch our application and the SQLExecute calls start slowly and get...
4
by: Bri | last post by:
Hi, First let me explain the process I have going on, then I'll address the problems I'm having: 1) Insert records in a temp table using a query 2) Using a query that joins the temp table with...
6
by: MadMan2004 | last post by:
Hello all! I'm having a problem with a project I'm working on and I'd like to ask for anyone's input that might be helpful. I'm building a rather large front-end application connecting to an...
20
by: John Bailo | last post by:
I have a c# program that loops through a table on a DB2 database. On each iteration it assigns data to values in the SqlParameter collection. The command text is an INSERT statement to a Sql...
9
by: dan | last post by:
within a loop i am building a sql insert statement to run against my (programatically created) mdb. it works but it seems unreasonably SLOW! Sorry, dont have the code here but the jist is very...
21
by: lesperancer | last post by:
I've got an access97 reporting mdb that pulls data (77,000 rows) from a sql server table into a local table to run reports if the local table is part of the reporting MDB, the insert statement...
1
by: Purple-D | last post by:
Hi All, I came across a weird situation today. We have a simple sql statement with some java code thrown around it which executes in about 1-2 seconds. However when put in input parameter...
2
by: william.david.anderson | last post by:
Hi there, I'm thinking of using a PREPARE statement inside a stored procedure, but am wondering about the performance penalty associated with calling PREPARE multiple times. Below is an...
0
by: Kerem Gümrükcü | last post by:
Hi, i use the code from this code sample on MSDN: for printing a 5 and sometimes 70 page text-only data: http://msdn.microsoft.com/en-us/library/ms404294.aspx The point is, that this is...
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:
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.