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

Slow prepare

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 markers in the same sql
stmt, do a preparestatement and then bind the appropriate parameters
using setXX etc (with the same values), the statements runs in close
to 20-25 seconds.

Why should there be so much difference in the total execution times
when running through the prepare statement in java ?

I did do run the same sql through db2batch and the prepare time is
almost negligible, and the fact that it runs in 1-2 seconds without
"prepare" indicates that the query itself is not a problem.

There is one thing that I noticed which might be pertinent to this,
upon looking at the output of the statement event monitor the user_cpu
times for both executions remain same, however the system_cpu time is
way higher for prepared statements. Also there are no index physical
reads when running directly but quite a few index physical reads when
running through prepared stmt

Any insights ?

(DB2 V8.2.5 on 32bit Aix 5.2)( bufferpool data hit 89% index hit 95%,
Some sort overflows but they remain consitent in both queries and so I
dont think they are contributing to 'this' problem atleast!)

P

Feb 15 '07 #1
1 2636
"Purple-D" <pa******@gmail.comwrote in message
news:11*********************@s48g2000cws.googlegro ups.com...
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 markers in the same sql
stmt, do a preparestatement and then bind the appropriate parameters
using setXX etc (with the same values), the statements runs in close
to 20-25 seconds.

Why should there be so much difference in the total execution times
when running through the prepare statement in java ?

I did do run the same sql through db2batch and the prepare time is
almost negligible, and the fact that it runs in 1-2 seconds without
"prepare" indicates that the query itself is not a problem.

There is one thing that I noticed which might be pertinent to this,
upon looking at the output of the statement event monitor the user_cpu
times for both executions remain same, however the system_cpu time is
way higher for prepared statements. Also there are no index physical
reads when running directly but quite a few index physical reads when
running through prepared stmt

Any insights ?

(DB2 V8.2.5 on 32bit Aix 5.2)( bufferpool data hit 89% index hit 95%,
Some sort overflows but they remain consitent in both queries and so I
dont think they are contributing to 'this' problem atleast!)

P
If the distribution of data is highly skewed, then DB2 may use a different
access plan if it knows what the predicate literals are (without the
parameter markers) and can come up with a more efficient access plan.
Feb 15 '07 #2

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

Similar topics

9
by: Seán Meehan | last post by:
Hi, Hope somebody can help because i've looked everywhere else fo ran answer. I'm connecting to an Access table with 100+ rows of data of approx 20 columns wide. I'm using getstring to "Quickly"...
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...
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...
0
by: RG | last post by:
OleDbCommand.Prepare error: Size of parameter (VB.NET 2003) I need to do a SQL INSERT statement into an Access table, and I’d like to use the exact technique described in the Help file example...
7
by: Jim Crate | last post by:
I have a couple queries in a PL/PGSQL function which execute very slowly (around one minute each) which execute in .5 second when not executed from within the function. Is there any way to...
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...
11
by: TC | last post by:
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...
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...
2
Airslash
by: Airslash | last post by:
Hello, currently I'm working on a company project where they have created a custom FileOpenDialog component. In this component they have a function to get all the Physical drives on a system and...
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
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: 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...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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.