473,406 Members | 2,378 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,406 software developers and data experts.

strange behaviour with temporary tables

the pseudo code for my update is

for i = 1 to n;
insert k records into temp_table;

update a set c1 = (select c1 from temp_table where
temp_table.pk = a.pk), c2 = ( select c2 from
temp_table where temp_table.pk = a.pk)
where a.pk in (select pk from temp_table)

delete from temp_table
commit;
end for;

When the temp_table is created as a DB2 temporary table, the performance
degrades after each loop, but if temp_table is created as a regular DB2
table we see a consistent performance.

Also the number of row_reads (activity monitor) was found to be extremely
high.

The size of the table that is updated is around 70,000 and the temp_table
has 8192 rows.

Can anyone shed some light on what I am doing wrong? or if there are any
limitations on temporary table that I need to be aware of.

Thanks,
Sumanth
Feb 13 '06 #1
1 1366
Sumanth wrote:
the pseudo code for my update is

for i = 1 to n;
insert k records into temp_table;

update a set c1 = (select c1 from temp_table where
temp_table.pk = a.pk), c2 = ( select c2 from
temp_table where temp_table.pk = a.pk)
where a.pk in (select pk from temp_table) update a set (c1, c2) = (select c1, c2 ...)

delete from temp_table
commit;
end for;

When the temp_table is created as a DB2 temporary table, the performance
degrades after each loop, but if temp_table is created as a regular DB2
table we see a consistent performance.

This is APAR# IY77333 fixed in FP11 (never mind the description. It's
too narrow).
DB2 keeps adding rows to the end despite the delete because temp tables
are implicitly defined as APPEND ONLY. So you keep scanning more and
more empty space.
In FP11 DB2 detects a DELETE without WHERE clause on such a temp and
truncates.

However you would be better of declaring the table as ON COMMIT DELETE
ROWS. Simply skip the DELETE. Let COMMIT truncate for you.

Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
Feb 13 '06 #2

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

Similar topics

0
by: Ethel Aardvark | last post by:
I am running a 9.0.1 database on a W2K server and have come across some strange behaviour with a SQL query. I have a query which runs in a PL/SQL cursor which has several PL/SQL variables used to...
2
by: shaun roe | last post by:
Following up from my earlier post, where I pursued the line I outlined. Here is the MYFunc class implementation: MyFunc::MyFunc(int i):m_i(i){ ostringstream os; os<<"This number is "<<m_i;...
9
by: hfinster | last post by:
Hello, could somebody please shed light on the following problem with g++ (4.03 and 3.3.6 as well)? Obviously, the copy constructor is not executed, if I assign the result of a function call to...
0
by: Ethel Aardvark | last post by:
I am running a 9.0.1 database on a W2K server and have come across some strange behaviour with a SQL query. I have a query which runs in a PL/SQL cursor which has several PL/SQL variables used to...
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: 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
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...
0
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,...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.