473,836 Members | 1,509 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Dynamic statement cache on LUW

aj
DB2 LUW 8.1 fixpak 14
Red Hat EL AS 4.4

I'm trying to diagnose some nocturnal CPU pressure, and am trying to
understand the dynamic statement cache as it applies to LUW. The only
doc/redbooks I am finding are for Z/OS, which I am completely ignorant
of.

I am using only Java and JDBC in my applications. No static SQL.

How does dynamic statement cache work in LUW 8.1? Is there a local
statement cache? I think there is a global statement cache (based
upon the "get snapshot for dynamic sql on <db>" command), but how do I
control it? Is it always turned on? Can I change its size?

If I prepare a statement in a java app, will the compiled version
of the statement remain in the cache after I have closed the
PreparedStateme nt? Will it remain after the java program completely
exits?

Any help appreciated.

aj
Jun 27 '08 #1
3 5733
Ian
aj wrote:
DB2 LUW 8.1 fixpak 14
Red Hat EL AS 4.4

I'm trying to diagnose some nocturnal CPU pressure, and am trying to
understand the dynamic statement cache as it applies to LUW. The only
doc/redbooks I am finding are for Z/OS, which I am completely ignorant
of.

I am using only Java and JDBC in my applications. No static SQL.

How does dynamic statement cache work in LUW 8.1? Is there a local
statement cache? I think there is a global statement cache (based
upon the "get snapshot for dynamic sql on <db>" command), but how do I
control it? Is it always turned on? Can I change its size?
The package cache holds the compiled plans and its size is controlled
by the pckcachesz database config parameter. Not sure what you mean
by "local" vs. "global" statement cache (is this in relation to DPF?)

When another query is prepared, DB2 looks to see if the plan already
exists in the cache -- by using a byte-for-byte comparison of the SQL
statements. (i.e. "select * from t1" <"select * FROM t1"). If
the statements match *exactly*, DB2 will use the existing plan.

Note, many things will invalidate some/all entries in the cache, like
table changes, index changes, runstats, and "FLUSH PACKAGE CACHE
DYNAMIC"

Every statement that is executed goes into the cache. I don't know
the specific algorithm for how the cache is maintained, but it's
almost certainly LRU-based (least-recently-used).
If I prepare a statement in a java app, will the compiled version
of the statement remain in the cache after I have closed the
PreparedStateme nt? Will it remain after the java program completely
exits?
Yes, and yes.

Jun 27 '08 #2
"aj" <ro****@mcdonal ds.comwrote in message
news:Ne******** *************** *******@superne ws.com...
DB2 LUW 8.1 fixpak 14
Red Hat EL AS 4.4

I'm trying to diagnose some nocturnal CPU pressure, and am trying to
understand the dynamic statement cache as it applies to LUW. The only
doc/redbooks I am finding are for Z/OS, which I am completely ignorant
of.

I am using only Java and JDBC in my applications. No static SQL.

How does dynamic statement cache work in LUW 8.1? Is there a local
statement cache? I think there is a global statement cache (based
upon the "get snapshot for dynamic sql on <db>" command), but how do I
control it? Is it always turned on? Can I change its size?

If I prepare a statement in a java app, will the compiled version
of the statement remain in the cache after I have closed the
PreparedStateme nt? Will it remain after the java program completely
exits?

Any help appreciated.

aj
Package cache is global (for the database) and packages are not flushed out
when a connection that created the package is closed. They can be used by
any application connection. If DB2 finds an (absolutely) identical SQL
statements already in cache, it will use that access plan and will not have
to calculate a new one. The text of the SQL must be identical, including
spaces, etc.

It is best to use prepared statements with parameter makers ("?") if the
predicates change from one execution to the next, so that DB2 can reuse the
package in cache. If you use literals in the predicate, each statement will
be different, and little reuse will be possible.

The size is controlled by the PCKCACHESZ parm in the database configuration
(get db config for db-name). You can monitor package cache overflow in the
application snapshot.
Jun 27 '08 #3
This goes with other answers.
At prep time, DB2 does a "lookup" in the cache to see if statement is
there. If yes execution willhappen. If not, it is compiled and then
DB2 "inserts" it in the cache, if there is room. If not, then an LRU
algorithm is used to inser it. It will stay there, even after a
connect reset, until DB2 needs the room.
If there's no room because all statements are servicing connections
then the cache will self extend. This will happen until the request
claims all available memory as defined in DATABASE_MEMORY parameter.
A snapshot, like db2mtrk command output, would show you the value
defined/value currently used/value high water mark.
I also believe but not quite sure as I haven't verified lately, that
DB2 will "park" the compiled statement in the application agent
private memory if all conditions stated above cannot make room for the
insertion. The idea being you should not get a no room available to
store your statement once compiled.
Reegards, Pierre.

On Apr 28, 2:09*pm, aj <ron...@mcdonal ds.comwrote:
DB2 LUW 8.1 fixpak 14
Red Hat EL AS 4.4

I'm trying to diagnose some nocturnal CPU pressure, and am trying to
understand the dynamic statement cache as it applies to LUW. *The only
doc/redbooks I am finding are for Z/OS, which I am completely ignorant
of.

I am using only Java and JDBC in my applications. * No static SQL.

How does dynamic statement cache work in LUW 8.1? * Is there a local
statement cache? *I think there is a global statement cache (based
upon the "get snapshot for dynamic sql on <db>" command), but how do I
control it? *Is it always turned on? *Can I change its size?

If I prepare a statement in a java app, will the compiled version
of the statement remain in the cache after I have closed the
PreparedStateme nt? *Will it remain after the java program completely
exits?

Any help appreciated.

aj
Jun 27 '08 #4

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

Similar topics

14
14892
by: Ina Schmitz | last post by:
Hello, I would like to get the logical and physical reads for every sql statement executed. Thatfore, I used the command "db2 get snapshot for dynamic sql on <mydatabase>". There, I could see the logical and physical reads from bufferpool for every statement monitored. Am I right? But now, I would like to read these results out of a table so that I could process them automatically. In which table(s) are the results of snapshot for...
0
2141
by: Martin | last post by:
Hi. I had a very frustrating afternoon and evening but I have got it all under control now so all of a sudden I am in a good mood. I want to share some insights on output caching with you lot. After looking at the use of the OutputCache directive and tinkering with it a bit I found its usability.very limited. Think of it: it is okay for static content. Well that's nice but no big deal. Static content is cheap anyway, the file system...
3
2773
by: PaulR | last post by:
Hi, I am trying to understand what invalidates Dynamic Packages in the Package Cache. By monitoring the Size of the Package Cache, it appears the following does 1. Performing a Runstats on all Tables reduces the Used Package Cache from some 200+MB to about 30MB ??
3
3911
by: sethwai | last post by:
Hi, I find the "snapshot for dynamic sql" a great tool for identifying the most frequently executed dynamic sql statements, most cpu used, etc. It is a great help for system tuning. My understanding is it does not display static sql statements. Is a statement event monitor the only way to capture the same information for static sql in packages? Lew
7
3030
by: Ronald S. Cook | last post by:
I've always been taught that stored procedures are better than writing SQL in client code for a number of reasons: - runs faster as is compiled and lives on the database server - is the more proper tier to put it since is a data function But then I've heard that writing SQL in my client .NET code might run just as fast? Dynamic SQL or something? And then there's LINQ on the horizon. Is it a successor to everything
0
1607
by: lekhrajm | last post by:
Hi, I want to flush Dynamic Sql CACHE completely in db2 9.1.2 I used command "db2 FLUSH PACKAGE CACHE DYNAMIC". But it lefts some queries in cache. These are fixed queries. It creats problem for me to find out top 10 queries with high hit ratio, using table function snap_get_dyn_sql_v91(). These queries come in top 10 most of the time. Is there any way to flush dynamic sql cache completely.
0
1889
by: Ian | last post by:
Patrick Finnegan wrote: Yes. It doesn't matter where you execute the statement from. Is your question of "how do I check" asking how you check whether it works when executed from a client? Or are you asking how you check if the cache was actually flushed? If this is the case, compare the output from 'db2pd -db X -dynamic' before and after you flush the cache. Of course, you'll need to be
6
7975
by: =?ISO-8859-1?Q?Tim_B=FCthe?= | last post by:
Hi, we are building a Java webapplication using JSF, running on websphere, querying a DB2 9 on Suse Enterprise 10. The app uses JDBC and PreparedStatements only (aka dynamic SQL). Every night, there is a ETL which deletes most of the data in the database and fills it all new. We observed very bad performance for some statements that ran for minutes (The queried table is about 100,000 records and the result is about 500 rows)....
2
8965
by: Damir | last post by:
Hello! I have noticed that after (sucessfully) executing the command: FLUSH PACKAGE CACHE DYNAMIC the dynamic SQL statement cache is not completely cleared (some of the dynamic SQL statement elements are not reset). For example, looking at the dynamic SQL snapshot I see a certain SQL statement that has been executed a number of times and has read a (big) number of rows. Then I execute the "FLUSH PACKAGE CACHE DYNAMIC" command.
0
9820
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, weíll explore What is ONU, What Is Router, ONU & Routerís main usage, and What is the difference between ONU and Router. Letís take a closer look ! Part I. Meaning of...
0
9670
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10548
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10591
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10254
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6979
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5826
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4452
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4016
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.