Solved

DB2 Temporary tablespace

Posted on 2009-05-07
7
3,819 Views
Last Modified: 2012-05-06
We encountered this issue:
[DB2]A temporary table space with sufficient page size does not exist.

By default, we create a temporary tablespace defines as User temporary tablespace. We were able to fix this by adding a System temporary tablespace using WEBMBUFF.

Questions:

What is the differnce between SYSTEM and USER temporary tablespaces?
Why would creating a System versus User temporary tablespace fix this?
CREATE 
PROCEDURE XYZ_TABLESPACES_TMP() 
    BEGIN    
      DECLARE V_COUNT INT DEFAULT 0;
      DECLARE STATEMENT VARCHAR(1000);
      SELECT COUNT(*)  INTO V_COUNT  FROM SYSIBM.SYSTABLESPACES
      WHERE TBSPACE = 'XYZTEMP';
      IF (V_COUNT = 0) THEN
        SET statement =  'CREATE USER TEMPORARY TABLESPACE XYZTEMP PAGESIZE 32K MANAGED BY SYSTEM USING (''XYZTEMP'') BUFFERPOOL  XYZBUFF';
       EXECUTE IMMEDIATE statement; 
    END IF;             
   END
/
 
as
 
CREATE 
PROCEDURE XYZ_TABLESPACES_TMP() 
    BEGIN    
      DECLARE V_COUNT INT DEFAULT 0;
      DECLARE STATEMENT VARCHAR(1000);
      SELECT COUNT(*)  INTO V_COUNT  FROM SYSIBM.SYSTABLESPACES
      WHERE TBSPACE = 'XYZTEMP';
      IF (V_COUNT = 0) THEN
        SET statement =  'CREATE SYSTEM TEMPORARY TABLESPACE XYZTEMP PAGESIZE 32K MANAGED BY SYSTEM USING (''XYZTEMP'') BUFFERPOOL  XYZBUFF';
       EXECUTE IMMEDIATE statement; 
    END IF;             
   END
/

Open in new window

0
Comment
Question by:mbevilacqua
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
7 Comments
 
LVL 45

Accepted Solution

by:
Kent Olsen earned 500 total points
ID: 24327066
Hi mbevilacqua,

The System and User temporary space areas are used for completely different things.  Though the lines can get a little blurry as to which type of space is requred for a particular operation.

As a query is executed, most operations are done in user temp space.  When a table (or subtable) is sorted, the results are written back to the user temp.  (Note that the table may be sorted even if the SQL didn't include a SORT clause.)  The sort operation itself may use space in the system temp area.  If the entire sort doesn't fit into memory, then the system temp is used as a sort of "paging" area for the sort process.

Without seeing your SQL it's impossible to know why it required SYSTEM temp space, but there are perfectly legitimate reasons.


Good Luck,
Kent


0
 

Author Comment

by:mbevilacqua
ID: 24327478
So our applicaiton needs to use 32k pagesizes. Does this mean we need to create a USER 32k temp and a SYSTEM 32k temp?

SQL: select xyzcolumn from tablexyz where xyzcolumn=1 order by xyzcolumn
0
 
LVL 37

Expert Comment

by:momi_sabag
ID: 24327516
the best way to find out would to just try it with only the system temp tablespace
if it would work - you don't need the user tablespace
if it won't work, you do need it
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:mbevilacqua
ID: 24327710
Easier said then done. We produce software and ship it to hundreds of customers. We need to know at ship time is it is required. I guess we can do a complete regresion test and see if converting the create from USER to SYSTEM causes any problems, but that is a big task.

The odd thing is that we have only used USER temp space for years. This is the first time we have seen this issue and the requirement for a System temp space.
0
 
LVL 45

Expert Comment

by:Kent Olsen
ID: 24327771
Hi mbevilacqua,

There's always SYSTEM temp space.  It's just that the default amount is just fine for most installations.

Creating a user temporary table in the SYSTEM temporary space is a bad idea, particularly when you're distributing "shrink wrapped" software and have little control over the user environments.  Better plans are to create another tablespace specifically for the temporary tables or just allow DB2 to manage the space.


Kent
0
 

Author Comment

by:mbevilacqua
ID: 24333218
We use regular table spaces with page size 32K to keep our data. So would we need to create system temporary table space with same page size or Is it enough IBM default table space 'TEMPSAPCE1' which is system temporary with page size 4k?
0
 
LVL 45

Expert Comment

by:Kent Olsen
ID: 24334683
The system temp space should be fine with 4K pages.  It doesn't typically hold user (row) data.


Kent
0

Featured Post

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As technology users and professionals, we’re always learning. Our universal interest in advancing our knowledge of the trade is unmatched by most industries. It’s a curiosity that makes sense, given the climate of change. Within that, there lies a…
When table data gets too large to manage or queries take too long to execute the solution is often to buy bigger hardware or assign more CPUs and memory resources to the machine to solve the problem. However, the best, cheapest and most effective so…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question