If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > LIST TABLESPACES vs SYSCAT.TABLES

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-18-07, 21:13
meehange meehange is offline
Registered User
 
Join Date: Jul 2004
Posts: 256
LIST TABLESPACES vs SYSCAT.TABLES

DB2 8.2 for SAP on AIX 5.3

Hey all,

I was just trying to figure out why there is a descrepency between the result of a LIST TABLESPACES SHOW DETAIL (which shows a particular tablespace has:
Total pages = 1275000
Useable pages = 1274976
Used pages = 935072
Free pages = 339904

Versus
Code:
db2 "select SUBSTR(TBSPACE,1,10) AS TABLESPACE, sum(CARD) as CARD, sum(NPAGES) as NPAGES, sum(FPAGES) as FPAGES from syscat.tables where TBSPACEID = 14 group by TBSPACE"
Which gives:
TABLESPACE CARD NPAGES FPAGES
---------- -------------------- ----------- -----------
MS1#PROTD 1592543 37169 37294

I've run stats on all tables.

What am I missing here?

Last edited by meehange; 04-18-07 at 21:17.
Reply With Quote
  #2 (permalink)  
Old 04-19-07, 09:38
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
Quote:
Originally Posted by meehange

What am I missing here?
Um... Indexes and LOBs?
Reply With Quote
  #3 (permalink)  
Old 04-19-07, 20:38
meehange meehange is offline
Registered User
 
Join Date: Jul 2004
Posts: 256
Quote:
Originally Posted by n_i
Um... Indexes and LOBs?
Nope, sorry...I should have said... all the indexes are in another tablespace. I don't believe there are any LOB's and in fact most of the tables in this tablespace are empty. The largest just got emptied out (7.5M rows deleted).

db2dart /lhwm yields:

Step #95: Object ID = 1034

=> EXPORT all data from table, drop the table, disconnect, reconnect,
recreate the table, and LOAD the data back into the table.

Table: SAPR3.DBTABLOG

DAT object size: 2
INX object size: 0
LF object size: 55040
LOB object size: 0
LOBA object size: 0
BMP object size: 0

Total size of object parts: 55042
Minimum number of extents that will move by this operation: 55042

Current highwater mark: 58440
Desired highwater mark: 0
Number of used extents in tablespace: 58441
Number of free extents below original HWM: 20364
Number of free extents below desired HWM: 0
Number of free extents below current HWM: 0

Now I see that it's suggesting that I drop and recreate the table, but I'm reluctant to do that until I understand why it's necessary....
Any ideas?
Reply With Quote
  #4 (permalink)  
Old 04-21-07, 05:10
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
There are a lot of information that we don't know:
  • is this the only table in the tablespace? (other tables could occupy space)
  • what kind of tablespace is that? (DMS tablespaces have things like a free space map)
  • have you run RUNSTATS recently? (if not, then the values in SYSCAT.TABLES may just be outdated)
  • was the table reorganized? (that would free up empty pages again)
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
  #5 (permalink)  
Old 04-24-07, 04:11
meehange meehange is offline
Registered User
 
Join Date: Jul 2004
Posts: 256
Quote:
Originally Posted by stolze
There are a lot of information that we don't know:[*] is this the only table in the tablespace? (other tables could occupy space)
No, there are several hundred tables in the tablespace, most are empty or close to empty. The largest has just had all it's rows deleted (7.5Mil) but the space doesn't seem to be freeing up.

Quote:
[*] what kind of tablespace is that? (DMS tablespaces have things like a free space map)
It's a DMS but the difference in space is far too large to be a mere overhead.

Quote:
[*] have you run RUNSTATS recently? (if not, then the values in SYSCAT.TABLES may just be outdated)
Runstats has been run very recently.

Quote:
[*] was the table reorganized? (that would free up empty pages again)
That's the problem, reorgs are not freeing up the space as I would have thought.

This problem has occurred on several systems now. I have managed to free up the space with the following procedure:

1. Rows deleted
2. Runstats on all tables in tablespace
3. Reorg all tables in tablespace
(this does not free up space)
4. Disconnect all application (I really don't want to do this on the production systems)
5. db2dart <DBID> /lhwm (giving the tablespace ID and 0 as the params)
This suggests a reorg with no access using the longlobdata option
6. Grep the output to get the tablenames in order
7. Create/run reorg statements based on the grep output (for some reason it only seems to work if the reorgs are done in the order advised by db2dart???)
--- the space is STILL not freed up----
8. db2stop (for some reason a FORCE is always required, I can't do this on Prod)/db2start
9. Runstats on all tables in tablespace

List tablespaces now shows the HWM and used pages has dropped and the tablespace can be resized (lowered by 90%)

So trhe problem/question is:

-How much of the above is Voodoo admin (ie stuff I'm doing because I think it's necessary)
-Why do I need to restart the instance to free the space, is this normal and can I avoid it?

Cheers,

Last edited by meehange; 04-24-07 at 04:16. Reason: missed a bit
Reply With Quote
  #6 (permalink)  
Old 04-24-07, 07:51
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
Quote:
Originally Posted by meehange
The largest has just had all it's rows deleted (7.5Mil) but the space doesn't seem to be freeing up.
Have you reorg'd that table to reclaim this free space? (This is one of the task that reorg does.)

Quote:
Runstats has been run very recently.
On all tables in the tablespace?

Quote:
That's the problem, reorgs are not freeing up the space as I would have thought.
In which table have you done the reorg? On all tables or just one?

Quote:
This problem has occurred on several systems now. I have managed to free up the space with the following procedure:

1. Rows deleted
2. Runstats on all tables in tablespace
3. Reorg all tables in tablespace
(this does not free up space)
4. Disconnect all application (I really don't want to do this on the production systems)
5. db2dart <DBID> /lhwm (giving the tablespace ID and 0 as the params)
This suggests a reorg with no access using the longlobdata option
6. Grep the output to get the tablenames in order
7. Create/run reorg statements based on the grep output (for some reason it only seems to work if the reorgs are done in the order advised by db2dart???)
--- the space is STILL not freed up----
8. db2stop (for some reason a FORCE is always required, I can't do this on Prod)/db2start
9. Runstats on all tables in tablespace
2. completely unnecessary step only adding overhead; you can collect statistics on the fly during reorg
3. does free up space; how do you do the reorg? (options)
7. repeats work from step 3. You could determine the tables with LONG/LOB columns before step 3 and use the LONGLOBDATA option in 3. already
8. why do you recycle db2? And if there are still some connections, you should figure out which ones those are
9. is again unnecessary if you collect statistics during the reorg phase
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
  #7 (permalink)  
Old 04-25-07, 20:25
meehange meehange is offline
Registered User
 
Join Date: Jul 2004
Posts: 256
Quote:
Originally Posted by stolze
Have you reorg'd that table to reclaim this free space? (This is one of the task that reorg does.)



On all tables in the tablespace?
Yes.
A 'reorg table <tablename> allow read access' run on all tables in the tablespace did not free up the space. It seems that only after a reorg with longlobdata option is run and then the instance restarted that the space is freed up and the HWM reduced.


Quote:
2. completely unnecessary step only adding overhead; you can collect statistics on the fly during reorg
3. does free up space; how do you do the reorg? (options)
7. repeats work from step 3. You could determine the tables with LONG/LOB columns before step 3 and use the LONGLOBDATA option in 3. already
8. why do you recycle db2? And if there are still some connections, you should figure out which ones those are
9. is again unnecessary if you collect statistics during the reorg phase
2. I'm on DB2 LUW 8.2, and I can't see any way collect stats on the fly during REORG. I was under the impression that best practice was runstats, reorg, runstats....no?

3. I have tried a classic reorg and an inplace reorg...neither seemed to do the trick.

7. Is there any harm in just specifying LONGLOBDATA for all tables in the tablespace? If not I might just do this.

8. It seems to me (and I have by no means rigorously tested this, since once the space is freed up I can't really recreate the exact situation again) that the space and HWM are only changed AFTER a recycle, which is the main problem here since I can't easily do a recycle when I move on to my production systems.

Cheers
Reply With Quote
  #8 (permalink)  
Old 04-26-07, 07:18
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
Quote:
Originally Posted by meehange
A 'reorg table <tablename> allow read access' run on all tables in the tablespace did not free up the space. It seems that only after a reorg with longlobdata option is run and then the instance restarted that the space is freed up and the HWM reduced.
Did you also reorg all indexes on those tables? If not, then indexes may occupy space.

Quote:
2. I'm on DB2 LUW 8.2, and I can't see any way collect stats on the fly during REORG. I was under the impression that best practice was runstats, reorg, runstats....no?
You are right. I mixed that up with REORGCHK.

Quote:
3. I have tried a classic reorg and an inplace reorg...neither seemed to do the trick.
As I said before, REORG frees unused space. I suggest that you pick one table and work through that first. Trying to handle all tables at once just complicates things.

Quote:
7. Is there any harm in just specifying LONGLOBDATA for all tables in the tablespace? If not I might just do this.
It may slow down the reorg process.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
  #9 (permalink)  
Old 04-30-07, 01:16
meehange meehange is offline
Registered User
 
Join Date: Jul 2004
Posts: 256
Knut,

All indexes are in a seperate tablespace. The space is being freed up and the HWM lowered, but only after an instance restart. Obviously this isn't desirable for 24/7 production systems. If I want an outage I have to explain why DB2 isn't operating as expected.....
Reply With Quote
  #10 (permalink)  
Old 04-30-07, 03:22
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
The HWM is lowered by RUNSTATS and/or REORG. But there are a few situations where it can't be lowered. Here is a nice summary in HWM and when it can/cannot be lowered by DB2:
http://www-1.ibm.com/support/docview...id=swg21006526
http://www****ban.de/DB2_luw/HWM_redu...reduction.html

Another question I have is why you want to lower the HWM? You delete a lot of data from the table. Wouldn't you expect the table to fill again at some later point in time? If so, then it doesn't make much sense to lower HWM and deallocate the already allocated extends. Allocating them again results in unnecessary overhead. So you should have another, compelling reason...
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
  #11 (permalink)  
Old 05-02-07, 00:27
meehange meehange is offline
Registered User
 
Join Date: Jul 2004
Posts: 256
Knut

These tables will not fill again to the same degree and will fill vey slowly, also other tablespaces are growing a lot faster and are in need of space. So I have to redistribute the space.

I understand that runstats/reorg will sometimes not reduce the HWM but this has happenned on 5 seperate DB's so far, so it looks like it always happens to these systems...perhaps it's an issue with SAP, I don't know.
My main concern is that I always need to restart the instance, and while I can do this on m test/dev systems...it's a real problem for my 24/7 systems (20 databases on 5 servers!!)
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On