0

We are implementing some system to our customers which uses DB2 database and we hadn't have problem with table spaces free pages before! But now in implementation phase I can see low level of database free pages. We had 56304 pages and now we have only 288 free. Can some one tell me does it can be harmful and dangerous? How to solve it? I tried with making some attributes of tables to decrease their size (on example ALN from 250 I set it to 100) but instead of growing my table spaces got smaller? How to solve this? I will be very thankful

4

2 回答 2

2

On Linux, UNIX, and Windows platforms, DB2 automatically grows its tablespaces unless they're explicitly defined otherwise. The following query will show you which tablespaces require manual resizing via the ALTER TABLESPACE command:

SELECT VARCHAR( RTRIM( tbsp_name ) || ' does not have AUTORESIZE enabled', 60 ) FROM sysibmadm.snaptbsp WHERE tbsp_type = 'DMS' AND tbsp_auto_resize_enabled <> 1 ;

If the above query returns no rows, then all of the tablespaces in your database will automatically grow as needed until there is no space left on the drive, volume, or file system that your database is using for storage.

When you alter a table to reduce the maximum size of one of its columns, that change won't affect existing rows in the table until they are modified by an UPDATE statement or a REORG TABLE command.

于 2012-06-07T22:26:12.727 回答
1

Yes, if you run out of free pages, then DB2 will not be able to write any more data to the table.

There are a few ways you can increase the number of free pages. You need to know how many file containers are assigned to the tablespace and how many free and used pages you have using the following query (or db2 list tablespaces show detail from the command line):

SELECT SUBSTR(TBSP_NAME,1,15) NAME
      ,TBSP_TYPE TYPE
      ,TBSP_AUTO_RESIZE_ENABLED AUTO_RESIZE
      ,TBSP_NUM_CONTAINERS CONTAINERS
      ,TBSP_TOTAL_PAGES TOTAL_PGS
      ,TBSP_USED_PAGES USED_PGS
      ,TBSP_FREE_PAGES FREE_PGS
      ,TBSP_MAX_SIZE MAX_SZ
      ,TBSP_PAGE_SIZE PG_SZ
FROM SYSIBMADM.TBSP_UTILIZATION
WHERE TBSP_CONTENT_TYPE IN ('ANY','SYSTEMP')

You can then calculate the number of pages to increase using the formula:

numPages = (usedPages - freePages) / numberOfContainersInTS

You'll then take the result and use ALTER TABLESPACE to extend the tablespace:

ALTER TABLESPACE <yourTS> EXTEND (ALL <numPages>)

Additionally, you may be able to REORG the table, which may free up some unused pages.

于 2012-06-07T18:21:37.280 回答