473,657 Members | 2,763 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Temporary table performance problem on UDB 8 on Linux


Folks,

I have a perl script that creates and uses global termporary table.
This script worked fine with UDB 7.2 on AIX. Sometime ago I moved the
database to UDB 8 on Linux. The select statement that used to take less
than a minute now take 10 minutes. Do I have to tune something on Linux
and/or DB2?

I tried two different ways to create temporary tablespace but both of
them give same slow performance:

Method 1:

db2 "create user temporary tablespace TEMPSPACE2 managed by system using ('/usr/local/home/db2gblcd/db2gblcd/UserTempSpace') "
db2 grant use of tablespace tempspace2 to public

Method 2:

db2 "create bufferpool tempspace2pool size 5 pagesize 32k"
db2 "create user temporary tablespace TEMPSPACE2 pagesize 32k managed by system using ('/usr/local/home/db2gblcd/db2gblcd/UserTempSpace') bufferpool tempspace2pool"
db2 grant use of tablespace tempspace2 to public
Here is the fragment of the code I am using:

$TmpTableStmt1 = "DECLARE GLOBAL TEMPORARY TABLE SESSION.FINAL (
PASS INTEGER,
SRC_NUM INTEGER
)
ON COMMIT PRESERVE ROWS
NOT LOGGED
IN TEMPSPACE2
;
CREATE INDEX FIDX1 ON SESSION.FINAL (SRC_NUM ASC);
CREATE INDEX FIDX2 ON SESSION.FINAL (PASS ASC);
";

eval
{
$TmpTableStmt1H andle = $DbHandle->prepare($TmpTa bleStmt1);
$TmpTableStmt1H andle->execute;
$TmpTableStmt1H andle->finish;
};

The code loops and inserts rows into the SESSION.FINAL table and
executeds a COMMIT statement. The code inserts between 70 and 100
rows into the table.

$InsertFinalStm t = "INSERT INTO SESSION.FINAL (PASS, SRC_NUM)
VALUES (?,?)";


This is the statement that now takes almost 10 minutes to execute.
$DependsOnStmt = "(SELECT LINE_NUM,
D.SRC_NUM AS SN,
D.DEPENDS_NUM,
'NONE',
'NONE'
FROM GBLCODE.DEPENDE NCY D, GBLCODE.SOURCEN AME S
WHERE DEPENDS_NUM IN
(SELECT SRC_NUM
FROM SESSION.FINAL
WHERE PASS = ?)
AND S.SRC_NUM NOT IN
(SELECT SRC_NUM
FROM SESSION.FINAL
WHERE PASS < ?)
AND D.SRC_NUM = S.SRC_NUM
UNION ALL
SELECT LINE_NUM,
M.SRC_NUM AS SN,
-1,
RTRIM(MOD_NUMBE R),
RTRIM(SWITCH)
FROM GBLCODE.MODCONT ROL M, GBLCODE.SOURCEN AME S
WHERE M.SRC_NUM IN
(SELECT SRC_NUM FROM GBLCODE.DEPENDE NCY
WHERE DEPENDS_NUM IN
(SELECT SRC_NUM
FROM SESSION.FINAL
WHERE PASS = ?)
AND S.SRC_NUM NOT IN
(SELECT SRC_NUM
FROM SESSION.FINAL
WHERE PASS < ?)
)
AND M.SRC_NUM = S.SRC_NUM
)
ORDER BY SN, LINE_NUM
FOR READ ONLY";

$DependsOnStmtH andle->execute($Pass, $Pass,$Pass,$Pa ss);
I checked stats on the tables in the above query and everything is looks
O.K. I even re-org'd the tables but no improvement.
--
Hemant Shah /"\ ASCII ribbon campaign
E-mail: No************@ xnet.com \ / ---------------------
X against HTML mail
TO REPLY, REMOVE NoJunkMail / \ and postings
FROM MY E-MAIL ADDRESS.
-----------------[DO NOT SEND UNSOLICITED BULK E-MAIL]------------------
I haven't lost my mind, Above opinions are mine only.
it's backed up on tape somewhere. Others can have their own.
Nov 12 '05 #1
11 4600
While stranded on information super highway Hemant Shah wrote:

Folks,

I have a perl script that creates and uses global termporary table.
This script worked fine with UDB 7.2 on AIX. Sometime ago I moved the
database to UDB 8 on Linux. The select statement that used to take less
than a minute now take 10 minutes. Do I have to tune something on Linux
and/or DB2?


I was monitoring the Linux system (2.4.18-14 kernel) and noticed that
the load average went up dramatically when I was running the query.

# top
1:14pm up 16 days, 15:44, 6 users, load average: 15.90, 13.86, 11.02
140 processes: 137 sleeping, 3 running, 0 zombie, 0 stopped
CPU states: 1.5% user, 10.5% system, 0.0% nice, 87.8% idle
Mem: 2582136K av, 2569444K used, 12692K free, 0K shrd, 6220K buff
Swap: 1542160K av, 131652K used, 1410508K free 2336268K cached

PID USER PRI NI SIZE RSS SHARE STAT %CPU %MEM TIME COMMAND
14713 db2gblcd 16 0 44984 31M 26520 R 2.9 1.2 36:02 db2sysc
6901 db2gblcd 16 0 45560 28M 27468 D 2.7 1.1 10:38 db2sysc
6903 db2gblcd 15 0 44392 30M 28824 D 0.9 1.2 13:09 db2sysc
2338 db2gblcd 15 0 43896 30M 26968 D 0.5 1.2 27:16 db2sysc

# uptime
1:16pm up 16 days, 15:45, 6 users, load average: 17.11, 14.67, 11.52

--
Hemant Shah /"\ ASCII ribbon campaign
E-mail: No************@ xnet.com \ / ---------------------
X against HTML mail
TO REPLY, REMOVE NoJunkMail / \ and postings
FROM MY E-MAIL ADDRESS.
-----------------[DO NOT SEND UNSOLICITED BULK E-MAIL]------------------
I haven't lost my mind, Above opinions are mine only.
it's backed up on tape somewhere. Others can have their own.
Nov 12 '05 #2
Ian
Hemant Shah wrote:
Folks,

I have a perl script that creates and uses global termporary table.
This script worked fine with UDB 7.2 on AIX. Sometime ago I moved the
database to UDB 8 on Linux. The select statement that used to take less
than a minute now take 10 minutes. Do I have to tune something on Linux
and/or DB2?

[...]

I checked stats on the tables in the above query and everything is looks
O.K. I even re-org'd the tables but no improvement.


Have you checked the access plan?

What about RUNSTATS on the GTT after it's been populated?


-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
Nov 12 '05 #3
What about the explain? Did it change between V7 and V8.
Could it be you get sort-overflows? Memory management has shifted a bit.
So it is a possibility that you receive an overflow where you didn't
before.....

Cheers
Serge
Nov 12 '05 #4
While stranded on information super highway Ian wrote:
Hemant Shah wrote:
Folks,

I have a perl script that creates and uses global termporary table.
This script worked fine with UDB 7.2 on AIX. Sometime ago I moved the
database to UDB 8 on Linux. The select statement that used to take less
than a minute now take 10 minutes. Do I have to tune something on Linux
and/or DB2?

> [...]

I checked stats on the tables in the above query and everything is looks
O.K. I even re-org'd the tables but no improvement.
Have you checked the access plan?


How do you check access plan on a dynamic SQL statement with GTT?

What about RUNSTATS on the GTT after it's been populated?
I did that too but same bad performance.


-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----


--
Hemant Shah /"\ ASCII ribbon campaign
E-mail: No************@ xnet.com \ / ---------------------
X against HTML mail
TO REPLY, REMOVE NoJunkMail / \ and postings
FROM MY E-MAIL ADDRESS.
-----------------[DO NOT SEND UNSOLICITED BULK E-MAIL]------------------
I haven't lost my mind, Above opinions are mine only.
it's backed up on tape somewhere. Others can have their own.
Nov 12 '05 #5
While stranded on information super highway Serge Rielau wrote:
What about the explain? Did it change between V7 and V8.
Could it be you get sort-overflows? Memory management has shifted a bit.
So it is a possibility that you receive an overflow where you didn't
before.....
How do I do explain on SQL statement with global temporary table?

Cheers
Serge


--
Hemant Shah /"\ ASCII ribbon campaign
E-mail: No************@ xnet.com \ / ---------------------
X against HTML mail
TO REPLY, REMOVE NoJunkMail / \ and postings
FROM MY E-MAIL ADDRESS.
-----------------[DO NOT SEND UNSOLICITED BULK E-MAIL]------------------
I haven't lost my mind, Above opinions are mine only.
it's backed up on tape somewhere. Others can have their own.
Nov 12 '05 #6
Easiest way is:

db2 connect to test
db2 DECLARE GLOBAL ....
db2 EXPLAIN PLAN FOR SELECT ......
db2exfmt -d test
<default> everything but the output file

Cheers
Serge
Nov 12 '05 #7
While stranded on information super highway Hemant Shah wrote:
While stranded on information super highway Ian wrote:
Hemant Shah wrote:
Folks,

I have a perl script that creates and uses global termporary table.
This script worked fine with UDB 7.2 on AIX. Sometime ago I moved the
database to UDB 8 on Linux. The select statement that used to take less
than a minute now take 10 minutes. Do I have to tune something on Linux
and/or DB2?

> [...]

I checked stats on the tables in the above query and everything is looks
O.K. I even re-org'd the tables but no improvement.
Have you checked the access plan?


How do you check access plan on a dynamic SQL statement with GTT?

What about RUNSTATS on the GTT after it's been populated?


I did that too but same bad performance.


I did runstats on regular tbles but no success. How do you do runstats
on a GTT from perl script?



-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----


--
Hemant Shah /"\ ASCII ribbon campaign
E-mail: No************@ xnet.com \ / ---------------------
X against HTML mail
TO REPLY, REMOVE NoJunkMail / \ and postings
FROM MY E-MAIL ADDRESS.
-----------------[DO NOT SEND UNSOLICITED BULK E-MAIL]------------------
I haven't lost my mind, Above opinions are mine only.
it's backed up on tape somewhere. Others can have their own.


--
Hemant Shah /"\ ASCII ribbon campaign
E-mail: No************@ xnet.com \ / ---------------------
X against HTML mail
TO REPLY, REMOVE NoJunkMail / \ and postings
FROM MY E-MAIL ADDRESS.
-----------------[DO NOT SEND UNSOLICITED BULK E-MAIL]------------------
I haven't lost my mind, Above opinions are mine only.
it's backed up on tape somewhere. Others can have their own.
Nov 12 '05 #8
While stranded on information super highway Serge Rielau wrote:
What about the explain? Did it change between V7 and V8.
Could it be you get sort-overflows? Memory management has shifted a bit.
So it is a possibility that you receive an overflow where you didn't
before.....

Cheers
Serge


I did some further testing and instead of using global temporary tables
I created another table in regular tablespace and used that in my query.

With regular table the query ran very fast.

There seems to be problem in the way global temporary tables are implemented
on Linux.
--
Hemant Shah /"\ ASCII ribbon campaign
E-mail: No************@ xnet.com \ / ---------------------
X against HTML mail
TO REPLY, REMOVE NoJunkMail / \ and postings
FROM MY E-MAIL ADDRESS.
-----------------[DO NOT SEND UNSOLICITED BULK E-MAIL]------------------
I haven't lost my mind, Above opinions are mine only.
it's backed up on tape somewhere. Others can have their own.
Nov 12 '05 #9
Hemand,

The code is independent of the platform.
Compare the plans of the good and the bad query.

Cheers
Serge
Nov 12 '05 #10

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

Similar topics

5
33629
by: Jim Garrison | last post by:
Scenario: 1) Create a GLOBAL TEMPORARY table and populate it with one (1) row. 2) Join that table to another with about 1 million rows. The join condition selects a few hundred rows. Performance: 4 seconds, the system is doing a full-table scan of the second table, and the Explain Plan output
1
21732
by: Stephen Miller | last post by:
Is it possible to ALTER a temporary table in TSQL (SQL2000)? The following TSQL reports a syntax error at the ALTER TABLE line: DECLARE @Test TABLE( NOT NULL , NOT NULL ) ALTER TABLE @Test DROP COLUMN Col2
18
8752
by: zebi | last post by:
hello, What's your opinion : The best type of temporary tablespace (DB2V7.2 SP 7 in AIX 4.3 / multiprocessor ) is DMS ou SMS ? Thanks ZEB
2
6968
by: Keith Watson | last post by:
Hi, we are currently implementing an application running on DB2 V7 on Z/OS using largely COBOL stored procedures, managed using WLM. Some of these stored procedures declared global temporary tables, which are declared with ON COMMIT DELETE ROWS to perform work on and then return these temporary tables to the client (which is a message driven EJB connecting via DB2 connect). The client reads the data in the result sets, creates some XML...
1
1375
by: Sumanth | last post by:
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)
1
2994
by: No bother | last post by:
If I have a procedure that will be run simultaneously by several people which requires the use of a temporary table is there a way for the table to be accessible only in the instance in which the procedure is being run so that multiple tables can have the same name but not have collisions? I would normally think to name the table with a random string but apparently SQL rules do not allow dynamically generated table names. The other thing...
11
6292
by: rawu | last post by:
hi , all . I got a question about creating indexes in db2 . a table has 44236333 rows an index planed to be build include 2 field ( 6 byte ) accordding to db2 document temporary tablespaces requirement size will be (6+9)*44236333*3.2/1024/1024/1024 = 1.98G
5
8818
by: Rahul B | last post by:
Hi, I have very little knowledge about creating Procedures/functions in DB2. When i tried to create the test function like CREATE FUNCTION GET_TEST (P_TEST_ID INTEGER, P_SEL_OR_SORT INTEGER,
6
3292
by: Troels Arvin | last post by:
Hello, I have recently run a rather large data import where the imported data i pumped through some updatable views equipped with INSTEAD OF triggers. For various reasons, the exact same data where imported into the exact same table/view/trigger structures (but with slightly different tablespace configuration, see later). The involved hardware was different (one running on x86_64, one running on PPC), but with comparable CPU, memory and...
0
8394
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
8732
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
8503
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
8605
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...
1
6164
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5632
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
4304
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2726
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
1955
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.