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

UDB V8.2 (FP1) - DGTT WITH REPLACE vs. delete * from DGTT

All:

Anyone had bad experience with doing DECLARE DGTT "WITH REPLACE"
option?
The suggested workaround was to do "DELETE FROM DGTT" sql statement.

We are seeing DGTT performance issue when replacing existing DGTT while
declaring it.

Which way is better?

Thanks!

Vijay

Nov 12 '05 #1
8 2604
UDBDBA wrote:
All:

Anyone had bad experience with doing DECLARE DGTT "WITH REPLACE"
option?
The suggested workaround was to do "DELETE FROM DGTT" sql statement.

We are seeing DGTT performance issue when replacing existing DGTT while
declaring it.

Look up: "Using temporary tables" The example is about CREATE/DROP, but
the same holds for REPLACE:
http://www-128.ibm.com/developerwork...dm-0501rielau/

Cheers
Serge

--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab
Nov 12 '05 #2
Hi Serge:

Thanks. I am using SQL PL profiler and have already read your technote.
It doens't say which way is faster (maybe i am not seeing the obvious
here). Do you think DGTT WITH REPLACE would be faster than DELETE rows
from DGTT?
The DECLARE "WITH REPLACE" option was taking up too much time (upto
1.5 seconds just to declare it with replace). The second highest is
opening a cursor which has reference to this temporary table. I have
SQLPL output. can i email you the screenshot please? (once again this
is for the "railroad application - TYES" :)

So the app. dev. team did the following to address DGTT slowdown:
1. Declare DGTT in the calling cobol program just once.
2. The cobol program is calling a stored procedure.
3. The stored procedure opens cursors which selects from regular tables
and the dgtt declared in the calling cobol program
4. Do insert/update operations on dgtt
5. Return control back to cobol code to delete rows from DGTT
Repeat step 1 thru 5

After doing the steps mentioned above, it is still slow and spends time
creating DGTT and declaring cursor on DGTT with other tables.

Any help is appreciated.

Vijay

Nov 12 '05 #3
Hi Vijay,

The (funky) DELETE will be faster.
The WITH REPLACE option will case the following codepath to execute:
* truncate the "old" temp table (free the space in the user temp)
* drop the DGTT
* invalidate all SQL statements which refer to this DGTT in this session
* declare the new temp
* recompile every SQL statement which refers to this DGTT in thsi
session as it executes teh first time.

Compare with (funky) delete:
* truncate the temp table
* done!

At the very minimum you will save CPU for the recompilation. The more
iterations the proc goes through the bigger the gain.
Note: Do not use a regular DELETE FROM SESSION.TEMP. First it will be
more codepath and second temps are append only, so you'll start leaking
user temp space.

Cheers
Serge
--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab
Nov 12 '05 #4
Hi Serge:

IMPORT or LOAD does not work on DGTT.
$ db2 " import from dummy.del of del replace into
SESSION.\"#ts155a_move_data\" "
SQL3015N An SQL error "-526" occurred during processing.
SQL0526N The requested function does not apply to declared temporary
tables.
SQLSTATE=42995
Can you elaborate on your note:

Compare with (funky) delete:
* truncate the temp table
* done!

Thanks.

Vijay

Nov 12 '05 #5
UDBDBA wrote:
Hi Serge:

IMPORT or LOAD does not work on DGTT.
$ db2 " import from dummy.del of del replace into
SESSION.\"#ts155a_move_data\" "
SQL3015N An SQL error "-526" occurred during processing.
SQL0526N The requested function does not apply to declared temporary
tables.
SQLSTATE=42995 Correct. Feel free to submit a requirement.
IMPORT is certainly not hard....
Can you elaborate on your note:

Compare with (funky) delete:
* truncate the temp table
* done!

Not much to elaborate.
When you declare tge global temp outside that loop of your then there
will be no statement ivalidation inside the loop, so no recompiles either.
Of course there will be be no DROP/DECLARE or DECLARE WITH REPLACE
because you moved it outside the loop.
So the only thing that's needed now is to do the DELETE.
Causing a run time error during a delete/update/insert to a global temp
which is NOT LOGGED will cause truncation (using the same algorithms
used on DROP/REPLACE.
So:
DELETE FROM SESSION.TEMP WHERE pk = CAST(raise_error('78000', 'bang') AS
INT);
will truncate the temp as efficient as possible.

If the cost simply moved from the DECLARE to the DELETE as seen in the
profiler, then that means that the cost was indeed mostly in the
truncation of temp.. Not much that can be done about that then....

Cheers
Serge

PS: Feel free to send me that screenshot
--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab
Nov 12 '05 #6
Hi Serge:

Awesome!

Does it mean that if we did the DELETE with raise_error, will it ONLY
truncate the temp table?
Does it invalidate the temp table which then invalidate other dependent
objects in that session?

I will send you the screenshot for the procedure (The proc does not
have the DECLARE and DELETE part in it). The cobol package has the
DECLARE WITH REPLACE and DELETE.

How can i measure the impact of DELCARE WITH REPLACE and DELETE
statements inside cobol programs? SQL PL Profiler is very nice for
stored procs!

Thank you,

Vijay

Nov 12 '05 #7
UDBDBA wrote:
Hi Serge:

Awesome!

Does it mean that if we did the DELETE with raise_error, will it ONLY
truncate the temp table? Yes Does it invalidate the temp table which then invalidate other dependent
objects in that session? No. It's TRUNCATE TABLE for humble developers. No unpleasant side-effects.
The semantics are: "on error - truncate" very different from a
persistent table with not logged which is "on error - drop pending"
I will send you the screenshot for the procedure (The proc does not
have the DECLARE and DELETE part in it). The cobol package has the
DECLARE WITH REPLACE and DELETE. ok
How can i measure the impact of DELCARE WITH REPLACE and DELETE
statements inside cobol programs? SQL PL Profiler is very nice for
stored procs!

Well.. the SQL PL Profiler actually does nothing magic.
It simply joins SYSCAT.STATEMENTS (containing package name, section
numbers AND source code line numbers) to the event monitor output
(containing package name, section number). Combine that with a shredded
source code (one line per row): voila!
If you look at the Java source it's all there for the taking.

Cheers
Serge

--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab
Nov 12 '05 #8
Hi Serge:

Thanks for clarifying. It is a "funky" delete -- Maybe, when we put in
the DCR we will suggest an option called FUNKY_DELETE with a flag Y or
N :)

Vijay

Nov 12 '05 #9

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

Similar topics

2
by: foo | last post by:
I'm creating a debug class called debug_mem_allocation for the purpose of finding memory leaks. I used macro's to replace the new and delete operators. My problem is with trying to replace the...
2
by: stabbert | last post by:
Can anyone confirm that the privelges needed to do an IMPORT with REPLACE have changed from 7.x to 8.x in DB2 UDB? I am finding the following definition in the online books for version 8 of DB2. ...
6
by: UDBDBA | last post by:
All: We are running UDB V8.2 FP8. We have sql query which uses DGTT. The access plan for the query changes based on rows selected into DGTT. 1. Secnario I: DGTT has atlest 1 row. I see INDEX...
5
by: Bob | last post by:
Hi Everybody I hope you can help. 2 related questions. 1. I am looking for a way to replace the confusing message box that comes up when a user trys to open a form without putting data in...
3
by: Niyazi | last post by:
Hi all, I have a dataTable that contains nearly 38400 rows. In the dataTable consist of 3 column. column 1 Name: MUHNO column 2 Name: HESNO Column 3 Name: BALANCE Let me give you some...
0
by: Laurence | last post by:
Hi folks, I cannot use "db2gcf -k" to remove db2 processes on DB2 ESE v9 FP1 and AIX5L v5.3 TL5 SP4 environment. The db2diag.log reports error as below: 2007-01-11-16.12.17.895783+480...
0
by: alexs | last post by:
Chaps, Up till now I've been using DB2 developer with my 9.1 databases quite happily. I recently applied FP1 to all my db2 systems and the developer workbench running on my laptop. since...
1
by: situ | last post by:
Hi, I'm using DB2 V9 for windows I'm inserting records into DGTT from select statement; the problem is how to insert unique value for every row inserted. I tried using “generated always as”...
29
by: shivasusan | last post by:
Hi! I can add rows with inputs to my HTML table dynamically using DOM, but I cannot remove selected rows. In fact, every row contains a Delete button. So, user selects the rows to remove, clicks...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: 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:
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
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...

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.