473,396 Members | 2,109 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,396 software developers and data experts.

Used Space for Tablespaces ESE/DPF

Have written a litte sql for showing the utilization of the tablespace.
(found it within the newsgroup from Paul Vernon).
Looks fine for an one Partition System only.
But how i can I see on which Partiton the Tablesapces reside.

select substr(TABLESPACE_NAME,1, 18) as TABLESPACE_NAME,
case when TABLESPACE_TYPE = 0
then 'DMS'
else 'SMS'
end as TBS_TYPE,
int(TOTAL_PAGES) as TOTAL_PAGES,
int(TOTAL_PAGES*PAGE_SIZE/1024/1024) as TOTAL_MB,
int(USED_PAGES) as USED_PAGES,
int(USED_PAGES*PAGE_SIZE/1024/1024) as USED_MB,
int(FREE_PAGES) as FREE_PAGES,
int(FREE_PAGES*PAGE_SIZE/1024/1024) as FREE_MB,
((USED_PAGES * 100) / TOTAL_PAGES) as PERC_USED
from table (snapshot_tbs_CFG(cast(null as varchar(20)), -2 )) as x
order by PERC_USED desc;

Output:

TABLESPACE_NAME TBS_TYPE TOTAL_PAGES TOTAL_MB USED_PAGES USED_MB
FREE_PAGES FREE_MB PERC_USED

------------------ -------- ----------- ----------- ----------- -----------
----------- ----------- --------------------

TEMPSPACE4 SMS 1 0 1 0
0 0 100

TEMPSPACE4 SMS 1 0 1 0
0 0 100

TEMPSPACE4 SMS 1 0 1 0
0 0 100

TEMPSPACE4 SMS 1 0 1 0
0 0 100

TEMPSPACE4 SMS 1 0 1 0
0 0 100

TEMPSPACE8K SMS 1 0 1 0
0 0 100

TEMPSPACE8K SMS 1409 11 1409 11
0 0 100

TEMPSPACE8K SMS 1409 11 1409 11
0 0 100

TEMPSPACE8K SMS 1409 11 1409 11
0 0 100

TEMPSPACE8K SMS 1409 11 1409 11
0 0 100

TEMPSPACE32K SMS 1 0 1 0
0 0 100

TEMPSPACE32K SMS 17 0 17 0
0 0 100

TEMPSPACE32K SMS 17 0 17 0
0 0 100

TEMPSPACE32K SMS 17 0 17 0
0 0 100

TEMPSPACE32K SMS 17 0 17 0
0 0 100

INDEXSPACE DMS 2560000 20000 2109456 16480
450512 3519 82

USERSPACE DMS 3000000 23437 2400736 18755
599200 4681 80

USERSPACE DMS 3000000 23437 2412256 18845
587680 4591 80

USERSPACE DMS 3000000 23437 2377088 18571
622848 4866 79
......

--

regards
Joachim Müller
Nov 12 '05 #1
8 2567
I don't believe you can get the partition number from the snapshot table
function. Use the following SQL to see partition numbers:

select substr(tbspace,1,18), tbspaceid, substr(t.dbpgname,1,18),
dbpartitionnum from syscat.tablespaces as t, syscat.dbpartitiongroupdef as d
where t.dbpgname = d.dbpgname;

You won't see any of your temp table spaces since SYSCAT.DBPARTITIONGROUPDEF
doesn't contain partition numbers for temp table spaces.
"Joachim Mueller" <jom0309@[--spam--]douglas-informatik.de> wrote in message
news:bu**********@news.dtag.de...
Have written a litte sql for showing the utilization of the tablespace.
(found it within the newsgroup from Paul Vernon).
Looks fine for an one Partition System only.
But how i can I see on which Partiton the Tablesapces reside.

select substr(TABLESPACE_NAME,1, 18) as TABLESPACE_NAME,
case when TABLESPACE_TYPE = 0
then 'DMS'
else 'SMS'
end as TBS_TYPE,
int(TOTAL_PAGES) as TOTAL_PAGES,
int(TOTAL_PAGES*PAGE_SIZE/1024/1024) as TOTAL_MB,
int(USED_PAGES) as USED_PAGES,
int(USED_PAGES*PAGE_SIZE/1024/1024) as USED_MB,
int(FREE_PAGES) as FREE_PAGES,
int(FREE_PAGES*PAGE_SIZE/1024/1024) as FREE_MB,
((USED_PAGES * 100) / TOTAL_PAGES) as PERC_USED
from table (snapshot_tbs_CFG(cast(null as varchar(20)), -2 )) as x
order by PERC_USED desc;

Output:

TABLESPACE_NAME TBS_TYPE TOTAL_PAGES TOTAL_MB USED_PAGES USED_MB
FREE_PAGES FREE_MB PERC_USED

------------------ -------- ----------- ----------- ----------- ---------- - ----------- ----------- --------------------

TEMPSPACE4 SMS 1 0 1 0 0 0 100

TEMPSPACE4 SMS 1 0 1 0 0 0 100

TEMPSPACE4 SMS 1 0 1 0 0 0 100

TEMPSPACE4 SMS 1 0 1 0 0 0 100

TEMPSPACE4 SMS 1 0 1 0 0 0 100

TEMPSPACE8K SMS 1 0 1 0 0 0 100

TEMPSPACE8K SMS 1409 11 1409 11 0 0 100

TEMPSPACE8K SMS 1409 11 1409 11 0 0 100

TEMPSPACE8K SMS 1409 11 1409 11 0 0 100

TEMPSPACE8K SMS 1409 11 1409 11 0 0 100

TEMPSPACE32K SMS 1 0 1 0 0 0 100

TEMPSPACE32K SMS 17 0 17 0 0 0 100

TEMPSPACE32K SMS 17 0 17 0 0 0 100

TEMPSPACE32K SMS 17 0 17 0 0 0 100

TEMPSPACE32K SMS 17 0 17 0 0 0 100

INDEXSPACE DMS 2560000 20000 2109456 16480 450512 3519 82

USERSPACE DMS 3000000 23437 2400736 18755 599200 4681 80

USERSPACE DMS 3000000 23437 2412256 18845 587680 4591 80

USERSPACE DMS 3000000 23437 2377088 18571 622848 4866 79
.....

--

regards
Joachim Müller

Nov 12 '05 #2
You can use the following query to get the partition information. I
hope you are aware that the snapshot table functions cannot be used
from remote clients because you cannot implicitly attach to the
instance from a remote client. This was in documented in known
problems and workaround docs in fp 3.
Thanks
Amit (singleton at canada.com)

WITH TEMP1 ( DBPGNAME, DBPARTITIONNUM, ALLNODES) AS ( SELECT DBPGNAME
,MIN(DBPARTITIONNUM) ,VARCHAR( CHAR(MIN(DBPARTITIONNUM)),50)
FROM SYSCAT.DBPARTITIONGROUPDEF A
GROUP BY DBPGNAME UNION ALL
SELECT A.DBPGNAME ,A.DBPARTITIONNUM, (RTRIM(B.ALLNODES) || ', ' ||
CHAR(A.DBPARTITIONNUM))
FROM SYSCAT.DBPARTITIONGROUPDEF A , TEMP1 B
WHERE A.DBPGNAME = B.DBPGNAME
AND A.DBPARTITIONNUM > B.DBPARTITIONNUM ),
TEMP2 (TBSPACE, DBPGNAME, ALLNODES) AS
( SELECT TBSPACE, F.DBPGNAME, F.ALLNODES FROM SYSCAT.TABLESPACES D
LEFT OUTER JOIN ( SELECT C.DBPGNAME, C.ALLNODES FROM TEMP1 C WHERE
DBPARTITIONNUM = ( SELECT MAX(DBPARTITIONNUM) FROM TEMP1 E WHERE
C.DBPGNAME = E.DBPGNAME)) F
ON D.DBPGNAME=F.DBPGNAME ),
TEMP3 (TBSPACE, DBPGNAME, PARTITIONS ) AS
(SELECT TBSPACE, COALESCE( DBPGNAME, 'IBMTEMPGROUP') , COALESCE(
ALLNODES, CHAR((SELECT DBPARTITIONNUM FROM SYSCAT.DBPARTITIONGROUPDEF
WHERE DBPGNAME='IBMCATGROUP' FETCH FIRST ROW ONLY )) ) FROM TEMP2)
SELECT SUBSTR(TABLESPACE_NAME,1, 18) AS TABLESPACE_NAME,
CASE WHEN TABLESPACE_TYPE = 0
THEN 'DMS'
ELSE 'SMS'
END AS TBS_TYPE,
INT(TOTAL_PAGES) AS TOTAL_PAGES,
INT(TOTAL_PAGES*PAGE_SIZE/1024/1024) AS TOTAL_MB,
INT(USED_PAGES) AS USED_PAGES,
INT(USED_PAGES*PAGE_SIZE/1024/1024) AS USED_MB,
INT(FREE_PAGES) AS FREE_PAGES,
INT(FREE_PAGES*PAGE_SIZE/1024/1024) AS FREE_MB,
((USED_PAGES * 100) / TOTAL_PAGES) AS PERC_USED, Y.DBPGNAME,
Y.PARTITIONS
FROM TABLE (SNAPSHOT_TBS_CFG(CAST(NULL AS VARCHAR(20)), -2 )) AS X
LEFT OUTER JOIN TEMP3 AS Y ON RTRIM(X.TABLESPACE_NAME)=
RTRIM(Y.TBSPACE)



"Bill Pellett" <wp******@prodigy.net> wrote in message news:<Xx*******************@newssvr31.news.prodigy .com>...
I don't believe you can get the partition number from the snapshot table
function. Use the following SQL to see partition numbers:

select substr(tbspace,1,18), tbspaceid, substr(t.dbpgname,1,18),
dbpartitionnum from syscat.tablespaces as t, syscat.dbpartitiongroupdef as d
where t.dbpgname = d.dbpgname;

You won't see any of your temp table spaces since SYSCAT.DBPARTITIONGROUPDEF
doesn't contain partition numbers for temp table spaces.
"Joachim Mueller" <jom0309@[--spam--]douglas-informatik.de> wrote in message
news:bu**********@news.dtag.de...
Have written a litte sql for showing the utilization of the tablespace.
(found it within the newsgroup from Paul Vernon).
Looks fine for an one Partition System only.
But how i can I see on which Partiton the Tablesapces reside.

select substr(TABLESPACE_NAME,1, 18) as TABLESPACE_NAME,
case when TABLESPACE_TYPE = 0
then 'DMS'
else 'SMS'
end as TBS_TYPE,
int(TOTAL_PAGES) as TOTAL_PAGES,
int(TOTAL_PAGES*PAGE_SIZE/1024/1024) as TOTAL_MB,
int(USED_PAGES) as USED_PAGES,
int(USED_PAGES*PAGE_SIZE/1024/1024) as USED_MB,
int(FREE_PAGES) as FREE_PAGES,
int(FREE_PAGES*PAGE_SIZE/1024/1024) as FREE_MB,
((USED_PAGES * 100) / TOTAL_PAGES) as PERC_USED
from table (snapshot_tbs_CFG(cast(null as varchar(20)), -2 )) as x
order by PERC_USED desc;

Output:

TABLESPACE_NAME TBS_TYPE TOTAL_PAGES TOTAL_MB USED_PAGES USED_MB
FREE_PAGES FREE_MB PERC_USED

------------------ -------- ----------- ----------- ----------- ----------

-
----------- ----------- --------------------

TEMPSPACE4 SMS 1 0 1

0
0 0 100

TEMPSPACE4 SMS 1 0 1

0
0 0 100

TEMPSPACE4 SMS 1 0 1

0
0 0 100

TEMPSPACE4 SMS 1 0 1

0
0 0 100

TEMPSPACE4 SMS 1 0 1

0
0 0 100

TEMPSPACE8K SMS 1 0 1

0
0 0 100

TEMPSPACE8K SMS 1409 11 1409

11
0 0 100

TEMPSPACE8K SMS 1409 11 1409

11
0 0 100

TEMPSPACE8K SMS 1409 11 1409

11
0 0 100

TEMPSPACE8K SMS 1409 11 1409

11
0 0 100

TEMPSPACE32K SMS 1 0 1

0
0 0 100

TEMPSPACE32K SMS 17 0 17

0
0 0 100

TEMPSPACE32K SMS 17 0 17

0
0 0 100

TEMPSPACE32K SMS 17 0 17

0
0 0 100

TEMPSPACE32K SMS 17 0 17

0
0 0 100

INDEXSPACE DMS 2560000 20000 2109456

16480
450512 3519 82

USERSPACE DMS 3000000 23437 2400736

18755
599200 4681 80

USERSPACE DMS 3000000 23437 2412256

18845
587680 4591 80

USERSPACE DMS 3000000 23437 2377088

18571
622848 4866 79
.....

--

regards
Joachim Müller

Nov 12 '05 #3
Amit,

thanks for your reply,

if I run your query ,it's not the result I expect:

WITH TEMP1 ( DBPGNAME, DBPARTITIONNUM, ALLNODES) AS ( SELECT DBPGNAME
,MIN(DBPARTITIONNUM) ,VARCHAR( CHAR(MIN(DBPARTITIONNUM)),50) FROM
SYSCAT.DBPARTITIONGROUPDEF A GROUP BY DBPGNAME UNION ALL SELECT A.DBPGNAME
,A.DBPARTITIONNUM, (RTRIM(B.ALLNODES) || ', ' || CHAR(A.DBPARTITIONNUM))
FROM SYSCAT.DBPARTITIONGROUPDEF A , TEMP1 B WHERE A.DBPGNAME = B.DBPGNAME
AND A.DBPARTITIONNUM > B.DBPARTITIONNUM ), TEMP2 (TBSPACE, DBPGNAME,
ALLNODES) AS ( SELECT TBSPACE, F.DBPGNAME, F.ALLNODES FROM
SYSCAT.TABLESPACES D LEFT OUTER JOIN ( SELECT C.DBPGNAME, C.ALLNODES FROM
TEMP1 C WHERE DBPARTITIONNUM = ( SELECT MAX(DBPARTITIONNUM) FROM TEMP1 E
WHERE C.DBPGNAME = E.DBPGNAME)) F ON D.DBPGNAME=F.DBPGNAME ), TEMP3
(TBSPACE, DBPGNAME, PARTITIONS ) AS (SELECT TBSPACE, COALESCE( DBPGNAME,
'IBMTEMPGROUP') , COALESCE( ALLNODES, CHAR((SELECT DBPARTITIONNUM FROM
SYSCAT.DBPARTITIONGROUPDEF WHERE DBPGNAME='IBMCATGROUP' FETCH FIRST ROW
ONLY )) ) FROM TEMP2) SELECT SUBSTR(TABLESPACE_NAME,1, 18) AS
TABLESPACE_NAME, CASE WHEN TABLESPACE_TYPE = 0 THEN 'DMS' ELSE 'SMS' END AS
TBS_TYPE, INT(TOTAL_PAGES) AS TOTAL_PAGES,
INT(TOTAL_PAGES*PAGE_SIZE/1024/1024) AS TOTAL_MB, INT(USED_PAGES) AS
USED_PAGES, INT(USED_PAGES*PAGE_SIZE/1024/1024) AS USED_MB, INT(FREE_PAGES)
AS FREE_PAGES, INT(FREE_PAGES*PAGE_SIZE/1024/1024) AS FREE_MB, ((USED_PAGES
* 100) / TOTAL_PAGES) AS PERC_USED, Y.DBPGNAME, Y.PARTITIONS FROM TABLE
(SNAPSHOT_TBS_CFG(CAST(NULL AS VARCHAR(20)), -2 )) AS X LEFT OUTER JOIN
TEMP3 AS Y ON RTRIM(X.TABLESPACE_NAME)= RTRIM(Y.TBSPACE)

TABLESPACE_NAME TBS_TYPE TOTAL_PAGES TOTAL_MB USED_PAGES USED_MB
FREE_PAGES FREE_MB PERC_USED DBPGNAME
PARTITIONS

------------------ -------- ----------- ----------- ----------- -----------
----------- ----------- -------------------- -------------------------------
----------------------------------------------------------------------------
--------------------- --------------------------------------------------

SQL0347W The recursive common table expression "DB2DWP.TEMP1" may contain
an

infinite loop. SQLSTATE=01605

DLP_IDX DMS 50000 390 36032 281
13952 109 72 USERGROUP
2, 5

DLP_IDX DMS 50000 390 36032 281
13952 109 72 USERGROUP
2, 3, 4, 5

DLP_IDX DMS 50000 390 36032 281
13952 109 72 USERGROUP
2, 4, 5

DLP_IDX DMS 50000 390 36032 281
13952 109 72 USERGROUP
2, 3, 5

DLP_IDX DMS 50000 390 36032 281
13952 109 72 USERGROUP
2, 5

DLP_IDX DMS 50000 390 36032 281
13952 109 72 USERGROUP
2, 3, 4, 5

DLP_IDX DMS 50000 390 36032 281
13952 109 72 USERGROUP
2, 4, 5

DLP_IDX DMS 50000 390 36032 281
13952 109 72 USERGROUP
2, 3, 5

DLP_IDX DMS 50000 390 36032 281
13952 109 72 USERGROUP
2, 5

DLP_IDX DMS 50000 390 36032 281
13952 109 72 USERGROUP
2, 3, 4, 5

DLP_IDX DMS 50000 390 36032 281
13952 109 72 USERGROUP
2, 4, 5

DLP_IDX DMS 50000 390 36032 281
13952 109 72 USERGROUP
2, 3, 5

DLP_IDX DMS 50000 390 36032 281
13952 109 72 USERGROUP
2, 5

DLP_IDX DMS 50000 390 36032 281
13952 109 72 USERGROUP
2, 3, 4, 5

DLP_IDX DMS 50000 390 36032 281
13952 109 72 USERGROUP
2, 4, 5

DLP_IDX DMS 50000 390 36032 281
13952 109 72 USERGROUP
2, 3, 5

For each row I only need the Partition for the Tablespaces.

Regards,

Joachim

"Amit" <aa***@hotmail.com> schrieb im Newsbeitrag
news:85**************************@posting.google.c om...
You can use the following query to get the partition information. I
hope you are aware that the snapshot table functions cannot be used
from remote clients because you cannot implicitly attach to the
instance from a remote client. This was in documented in known
problems and workaround docs in fp 3.
Thanks
Amit (singleton at canada.com)

WITH TEMP1 ( DBPGNAME, DBPARTITIONNUM, ALLNODES) AS ( SELECT DBPGNAME
,MIN(DBPARTITIONNUM) ,VARCHAR( CHAR(MIN(DBPARTITIONNUM)),50)
FROM SYSCAT.DBPARTITIONGROUPDEF A
GROUP BY DBPGNAME UNION ALL
SELECT A.DBPGNAME ,A.DBPARTITIONNUM, (RTRIM(B.ALLNODES) || ', ' ||
CHAR(A.DBPARTITIONNUM))
FROM SYSCAT.DBPARTITIONGROUPDEF A , TEMP1 B
WHERE A.DBPGNAME = B.DBPGNAME
AND A.DBPARTITIONNUM > B.DBPARTITIONNUM ),
TEMP2 (TBSPACE, DBPGNAME, ALLNODES) AS
( SELECT TBSPACE, F.DBPGNAME, F.ALLNODES FROM SYSCAT.TABLESPACES D
LEFT OUTER JOIN ( SELECT C.DBPGNAME, C.ALLNODES FROM TEMP1 C WHERE
DBPARTITIONNUM = ( SELECT MAX(DBPARTITIONNUM) FROM TEMP1 E WHERE
C.DBPGNAME = E.DBPGNAME)) F
ON D.DBPGNAME=F.DBPGNAME ),
TEMP3 (TBSPACE, DBPGNAME, PARTITIONS ) AS
(SELECT TBSPACE, COALESCE( DBPGNAME, 'IBMTEMPGROUP') , COALESCE(
ALLNODES, CHAR((SELECT DBPARTITIONNUM FROM SYSCAT.DBPARTITIONGROUPDEF
WHERE DBPGNAME='IBMCATGROUP' FETCH FIRST ROW ONLY )) ) FROM TEMP2)
SELECT SUBSTR(TABLESPACE_NAME,1, 18) AS TABLESPACE_NAME,
CASE WHEN TABLESPACE_TYPE = 0
THEN 'DMS'
ELSE 'SMS'
END AS TBS_TYPE,
INT(TOTAL_PAGES) AS TOTAL_PAGES,
INT(TOTAL_PAGES*PAGE_SIZE/1024/1024) AS TOTAL_MB,
INT(USED_PAGES) AS USED_PAGES,
INT(USED_PAGES*PAGE_SIZE/1024/1024) AS USED_MB,
INT(FREE_PAGES) AS FREE_PAGES,
INT(FREE_PAGES*PAGE_SIZE/1024/1024) AS FREE_MB,
((USED_PAGES * 100) / TOTAL_PAGES) AS PERC_USED, Y.DBPGNAME,
Y.PARTITIONS
FROM TABLE (SNAPSHOT_TBS_CFG(CAST(NULL AS VARCHAR(20)), -2 )) AS X
LEFT OUTER JOIN TEMP3 AS Y ON RTRIM(X.TABLESPACE_NAME)=
RTRIM(Y.TBSPACE)



"Bill Pellett" <wp******@prodigy.net> wrote in message

news:<Xx*******************@newssvr31.news.prodigy .com>...
I don't believe you can get the partition number from the snapshot table
function. Use the following SQL to see partition numbers:

select substr(tbspace,1,18), tbspaceid, substr(t.dbpgname,1,18),
dbpartitionnum from syscat.tablespaces as t, syscat.dbpartitiongroupdef as d where t.dbpgname = d.dbpgname;

You won't see any of your temp table spaces since SYSCAT.DBPARTITIONGROUPDEF doesn't contain partition numbers for temp table spaces.
"Joachim Mueller" <jom0309@[--spam--]douglas-informatik.de> wrote in message news:bu**********@news.dtag.de...
Have written a litte sql for showing the utilization of the tablespace. (found it within the newsgroup from Paul Vernon).
Looks fine for an one Partition System only.
But how i can I see on which Partiton the Tablesapces reside.

select substr(TABLESPACE_NAME,1, 18) as TABLESPACE_NAME,
case when TABLESPACE_TYPE = 0
then 'DMS'
else 'SMS'
end as TBS_TYPE,
int(TOTAL_PAGES) as TOTAL_PAGES,
int(TOTAL_PAGES*PAGE_SIZE/1024/1024) as TOTAL_MB,
int(USED_PAGES) as USED_PAGES,
int(USED_PAGES*PAGE_SIZE/1024/1024) as USED_MB,
int(FREE_PAGES) as FREE_PAGES,
int(FREE_PAGES*PAGE_SIZE/1024/1024) as FREE_MB,
((USED_PAGES * 100) / TOTAL_PAGES) as PERC_USED
from table (snapshot_tbs_CFG(cast(null as varchar(20)), -2 )) as x
order by PERC_USED desc;

Output:

TABLESPACE_NAME TBS_TYPE TOTAL_PAGES TOTAL_MB USED_PAGES USED_MB FREE_PAGES FREE_MB PERC_USED

------------------ -------- ----------- ----------- ----------- ----------
-
----------- ----------- --------------------

TEMPSPACE4 SMS 1 0 1

0
0 0 100

TEMPSPACE4 SMS 1 0 1

0
0 0 100

TEMPSPACE4 SMS 1 0 1

0
0 0 100

TEMPSPACE4 SMS 1 0 1

0
0 0 100

TEMPSPACE4 SMS 1 0 1

0
0 0 100

TEMPSPACE8K SMS 1 0 1

0
0 0 100

TEMPSPACE8K SMS 1409 11 1409

11
0 0 100

TEMPSPACE8K SMS 1409 11 1409

11
0 0 100

TEMPSPACE8K SMS 1409 11 1409

11
0 0 100

TEMPSPACE8K SMS 1409 11 1409

11
0 0 100

TEMPSPACE32K SMS 1 0 1

0
0 0 100

TEMPSPACE32K SMS 17 0 17

0
0 0 100

TEMPSPACE32K SMS 17 0 17

0
0 0 100

TEMPSPACE32K SMS 17 0 17

0
0 0 100

TEMPSPACE32K SMS 17 0 17

0
0 0 100

INDEXSPACE DMS 2560000 20000 2109456

16480
450512 3519 82

USERSPACE DMS 3000000 23437 2400736

18755
599200 4681 80

USERSPACE DMS 3000000 23437 2412256

18845
587680 4591 80

USERSPACE DMS 3000000 23437 2377088

18571
622848 4866 79
.....

--

regards
Joachim Müller

Nov 12 '05 #4
Not sure if I understand correctly. The last column of the query I
posted showns the partitions that the tablespace exists on. The
tablespace will exist on all partitions of the nodegroup (database
partition group) that its defined on - not just one partition.

Thanks
Amit
Nov 12 '05 #5
oops - realised my query had some problems - here's the one that
calculates the aggregates and returns the total for each tablespace
If you want a query that returns the partition number for each row
instead of aggregate, you can also achive that similarly using sql
recursion (pass in the next node number as the secomd argument in
SNAPSHOT_TBS_CFG ). I think partition number should be in the result
set (and monitor elements) for tablespaces but was proabably left out
due to an oversight.
WITH TEMP1 ( DBPGNAME, DBPARTITIONNUM, ALLNODES, LEVEL) AS ( SELECT
DBPGNAME
,MIN(DBPARTITIONNUM) ,VARCHAR( CHAR(MIN(DBPARTITIONNUM)),50), 0
FROM SYSCAT.DBPARTITIONGROUPDEF A
GROUP BY DBPGNAME UNION ALL
SELECT A.DBPGNAME ,A.DBPARTITIONNUM, (RTRIM(B.ALLNODES) || ', ' ||
CHAR(A.DBPARTITIONNUM)), B.LEVEL+1
FROM SYSCAT.DBPARTITIONGROUPDEF A , TEMP1 B
WHERE A.DBPGNAME = B.DBPGNAME
AND A.DBPARTITIONNUM > B.DBPARTITIONNUM
),
TEMP2 (TBSPACE, DBPGNAME, ALLNODES) AS
( SELECT TBSPACE, F.DBPGNAME, F.ALLNODES FROM SYSCAT.TABLESPACES D
LEFT OUTER JOIN ( SELECT C.DBPGNAME, C.ALLNODES FROM TEMP1 C WHERE
C.LEVEL = ( SELECT MAX(LEVEL) FROM TEMP1 E WHERE
C.DBPGNAME = E.DBPGNAME)) F
ON D.DBPGNAME=F.DBPGNAME ),
TEMP3 (TBSPACE, DBPGNAME, PARTITIONS ) AS
(SELECT TBSPACE, COALESCE( DBPGNAME, 'IBMTEMPGROUP') , COALESCE(
ALLNODES, CHAR((SELECT DBPARTITIONNUM FROM SYSCAT.DBPARTITIONGROUPDEF
WHERE DBPGNAME='IBMCATGROUP' FETCH FIRST ROW ONLY )) ) FROM TEMP2),
TEMP4 AS
(SELECT TABLESPACE_NAME , CASE WHEN TABLESPACE_TYPE = 0 THEN 'DMS'
ELSE 'SMS' END AS
TBS_TYPE, SUM(TOTAL_PAGES) AS TOTAL_PAGES,
SUM(TOTAL_PAGES*PAGE_SIZE)/1024/1024 AS TOTAL_MB, SUM(USED_PAGES) AS
USED_PAGES, SUM(USED_PAGES*PAGE_SIZE)/1024/1024 AS USED_MB,
SUM(FREE_PAGES)
AS FREE_PAGES, SUM(FREE_PAGES*PAGE_SIZE)/1024/1024 AS FREE_MB, CASE
WHEN SUM (TOTAL_PAGES) >0 THEN (SUM(USED_PAGES)
* 100 / SUM (TOTAL_PAGES) ) ELSE NULL END AS PERC_USED FROM TABLE
(SNAPSHOT_TBS_CFG(CAST(NULL AS VARCHAR(20)), -2 )) AS A GROUP BY
TABLESPACE_NAME, TABLESPACE_TYPE )
SELECT A.*, B.DBPGNAME, B.PARTITIONS FROM TEMP4 A INNER JOIN TEMP3 B
ON RTRIM(A.TABLESPACE_NAME) = RTRIM(B.TBSPACE)


aa***@hotmail.com (Amit) wrote in message news:<85**************************@posting.google. com>...
Not sure if I understand correctly. The last column of the query I
posted showns the partitions that the tablespace exists on. The
tablespace will exist on all partitions of the nodegroup (database
partition group) that its defined on - not just one partition.

Thanks
Amit

Nov 12 '05 #6
Amit,

thanks once more, but (a big BUT) sometimes the PERC_USED column is equal on
all
partitions, but most the the differ from partition to partition.
What I want is to see which partition have reached the threshold for 85% so
I can resize the container
lying on this partition.

Here is a better sample:

TABLESPACE_NAME TBS_TYPE TOTAL_PAGES TOTAL_MB USED_PAGES USED_MB
FREE_PAGES FREE_MB PERC_USED

------------------ -------- ----------- ----------- ----------- -----------
----------- ----------- --------------------
USERSPACE DMS 3000000 23437 2382240 18611
617696 4825 79

USERSPACE DMS 3000000 23437 2410496 18832
589440 4605 80

USERSPACE DMS 3000000 23437 2406784 18803
593152 4634 80

USERSPACE DMS 3000000 23437 2421152 18915
578784 4521 80

INDEXSPACE DMS 2560000 20000 2022640 15801
537328 4197 79

INDEXSPACE DMS 2560000 20000 2024432 15815
535536 4183 79

INDEXSPACE DMS 2560000 20000 2014752 15740
545216 4259 78

INDEXSPACE DMS 2560000 20000 2096592 16379
463376 3620 81

You see that USERSPACE also INDEXSPACE have the same TOTAL_PAGES each on one
of the four partitions.
But USED_PAGES differs on the four partitions.

Sorry for my bad english, it's hard to explain something thats not my native
language;-)

regards,

Joachim

"Amit" <aa***@hotmail.com> schrieb im Newsbeitrag
news:85*************************@posting.google.co m...
oops - realised my query had some problems - here's the one that
calculates the aggregates and returns the total for each tablespace
If you want a query that returns the partition number for each row
instead of aggregate, you can also achive that similarly using sql
recursion (pass in the next node number as the secomd argument in
SNAPSHOT_TBS_CFG ). I think partition number should be in the result
set (and monitor elements) for tablespaces but was proabably left out
due to an oversight.
WITH TEMP1 ( DBPGNAME, DBPARTITIONNUM, ALLNODES, LEVEL) AS ( SELECT
DBPGNAME
,MIN(DBPARTITIONNUM) ,VARCHAR( CHAR(MIN(DBPARTITIONNUM)),50), 0
FROM SYSCAT.DBPARTITIONGROUPDEF A
GROUP BY DBPGNAME UNION ALL
SELECT A.DBPGNAME ,A.DBPARTITIONNUM, (RTRIM(B.ALLNODES) || ', ' ||
CHAR(A.DBPARTITIONNUM)), B.LEVEL+1
FROM SYSCAT.DBPARTITIONGROUPDEF A , TEMP1 B
WHERE A.DBPGNAME = B.DBPGNAME
AND A.DBPARTITIONNUM > B.DBPARTITIONNUM
),
TEMP2 (TBSPACE, DBPGNAME, ALLNODES) AS
( SELECT TBSPACE, F.DBPGNAME, F.ALLNODES FROM SYSCAT.TABLESPACES D
LEFT OUTER JOIN ( SELECT C.DBPGNAME, C.ALLNODES FROM TEMP1 C WHERE
C.LEVEL = ( SELECT MAX(LEVEL) FROM TEMP1 E WHERE
C.DBPGNAME = E.DBPGNAME)) F
ON D.DBPGNAME=F.DBPGNAME ),
TEMP3 (TBSPACE, DBPGNAME, PARTITIONS ) AS
(SELECT TBSPACE, COALESCE( DBPGNAME, 'IBMTEMPGROUP') , COALESCE(
ALLNODES, CHAR((SELECT DBPARTITIONNUM FROM SYSCAT.DBPARTITIONGROUPDEF
WHERE DBPGNAME='IBMCATGROUP' FETCH FIRST ROW ONLY )) ) FROM TEMP2),
TEMP4 AS
(SELECT TABLESPACE_NAME , CASE WHEN TABLESPACE_TYPE = 0 THEN 'DMS'
ELSE 'SMS' END AS
TBS_TYPE, SUM(TOTAL_PAGES) AS TOTAL_PAGES,
SUM(TOTAL_PAGES*PAGE_SIZE)/1024/1024 AS TOTAL_MB, SUM(USED_PAGES) AS
USED_PAGES, SUM(USED_PAGES*PAGE_SIZE)/1024/1024 AS USED_MB,
SUM(FREE_PAGES)
AS FREE_PAGES, SUM(FREE_PAGES*PAGE_SIZE)/1024/1024 AS FREE_MB, CASE
WHEN SUM (TOTAL_PAGES) >0 THEN (SUM(USED_PAGES)
* 100 / SUM (TOTAL_PAGES) ) ELSE NULL END AS PERC_USED FROM TABLE
(SNAPSHOT_TBS_CFG(CAST(NULL AS VARCHAR(20)), -2 )) AS A GROUP BY
TABLESPACE_NAME, TABLESPACE_TYPE )
SELECT A.*, B.DBPGNAME, B.PARTITIONS FROM TEMP4 A INNER JOIN TEMP3 B
ON RTRIM(A.TABLESPACE_NAME) = RTRIM(B.TBSPACE)


aa***@hotmail.com (Amit) wrote in message

news:<85**************************@posting.google. com>...
Not sure if I understand correctly. The last column of the query I
posted showns the partitions that the tablespace exists on. The
tablespace will exist on all partitions of the nodegroup (database
partition group) that its defined on - not just one partition.

Thanks
Amit

Nov 12 '05 #7
You will either need to run the Tablespace Snaphot Query separately
(maybe use a sql proc) for each partition (you can pass in the
partition number to the table function) or use recursive sql (using a
common table expression) to call the table function repeatedly with
different partition numbers and show the results with the partition
number as the last column.

"Joachim Mueller" <jom0309@[--spam--]douglas-informatik.de> wrote in message news:<bu**********@news.dtag.de>...
Amit,

thanks once more, but (a big BUT) sometimes the PERC_USED column is equal on
all
partitions, but most the the differ from partition to partition.
What I want is to see which partition have reached the threshold for 85% so
I can resize the container
lying on this partition.

Here is a better sample:

TABLESPACE_NAME TBS_TYPE TOTAL_PAGES TOTAL_MB USED_PAGES USED_MB
FREE_PAGES FREE_MB PERC_USED

------------------ -------- ----------- ----------- ----------- -----------
----------- ----------- --------------------
USERSPACE DMS 3000000 23437 2382240 18611
617696 4825 79

USERSPACE DMS 3000000 23437 2410496 18832
589440 4605 80

USERSPACE DMS 3000000 23437 2406784 18803
593152 4634 80

USERSPACE DMS 3000000 23437 2421152 18915
578784 4521 80

INDEXSPACE DMS 2560000 20000 2022640 15801
537328 4197 79

INDEXSPACE DMS 2560000 20000 2024432 15815
535536 4183 79

INDEXSPACE DMS 2560000 20000 2014752 15740
545216 4259 78

INDEXSPACE DMS 2560000 20000 2096592 16379
463376 3620 81

You see that USERSPACE also INDEXSPACE have the same TOTAL_PAGES each on one
of the four partitions.
But USED_PAGES differs on the four partitions.

Sorry for my bad english, it's hard to explain something thats not my native
language;-)

regards,

Joachim

"Amit" <aa***@hotmail.com> schrieb im Newsbeitrag
news:85*************************@posting.google.co m...
oops - realised my query had some problems - here's the one that
calculates the aggregates and returns the total for each tablespace
If you want a query that returns the partition number for each row
instead of aggregate, you can also achive that similarly using sql
recursion (pass in the next node number as the secomd argument in
SNAPSHOT_TBS_CFG ). I think partition number should be in the result
set (and monitor elements) for tablespaces but was proabably left out
due to an oversight.
WITH TEMP1 ( DBPGNAME, DBPARTITIONNUM, ALLNODES, LEVEL) AS ( SELECT
DBPGNAME
,MIN(DBPARTITIONNUM) ,VARCHAR( CHAR(MIN(DBPARTITIONNUM)),50), 0
FROM SYSCAT.DBPARTITIONGROUPDEF A
GROUP BY DBPGNAME UNION ALL
SELECT A.DBPGNAME ,A.DBPARTITIONNUM, (RTRIM(B.ALLNODES) || ', ' ||
CHAR(A.DBPARTITIONNUM)), B.LEVEL+1
FROM SYSCAT.DBPARTITIONGROUPDEF A , TEMP1 B
WHERE A.DBPGNAME = B.DBPGNAME
AND A.DBPARTITIONNUM > B.DBPARTITIONNUM
),
TEMP2 (TBSPACE, DBPGNAME, ALLNODES) AS
( SELECT TBSPACE, F.DBPGNAME, F.ALLNODES FROM SYSCAT.TABLESPACES D
LEFT OUTER JOIN ( SELECT C.DBPGNAME, C.ALLNODES FROM TEMP1 C WHERE
C.LEVEL = ( SELECT MAX(LEVEL) FROM TEMP1 E WHERE
C.DBPGNAME = E.DBPGNAME)) F
ON D.DBPGNAME=F.DBPGNAME ),
TEMP3 (TBSPACE, DBPGNAME, PARTITIONS ) AS
(SELECT TBSPACE, COALESCE( DBPGNAME, 'IBMTEMPGROUP') , COALESCE(
ALLNODES, CHAR((SELECT DBPARTITIONNUM FROM SYSCAT.DBPARTITIONGROUPDEF
WHERE DBPGNAME='IBMCATGROUP' FETCH FIRST ROW ONLY )) ) FROM TEMP2),
TEMP4 AS
(SELECT TABLESPACE_NAME , CASE WHEN TABLESPACE_TYPE = 0 THEN 'DMS'
ELSE 'SMS' END AS
TBS_TYPE, SUM(TOTAL_PAGES) AS TOTAL_PAGES,
SUM(TOTAL_PAGES*PAGE_SIZE)/1024/1024 AS TOTAL_MB, SUM(USED_PAGES) AS
USED_PAGES, SUM(USED_PAGES*PAGE_SIZE)/1024/1024 AS USED_MB,
SUM(FREE_PAGES)
AS FREE_PAGES, SUM(FREE_PAGES*PAGE_SIZE)/1024/1024 AS FREE_MB, CASE
WHEN SUM (TOTAL_PAGES) >0 THEN (SUM(USED_PAGES)
* 100 / SUM (TOTAL_PAGES) ) ELSE NULL END AS PERC_USED FROM TABLE
(SNAPSHOT_TBS_CFG(CAST(NULL AS VARCHAR(20)), -2 )) AS A GROUP BY
TABLESPACE_NAME, TABLESPACE_TYPE )
SELECT A.*, B.DBPGNAME, B.PARTITIONS FROM TEMP4 A INNER JOIN TEMP3 B
ON RTRIM(A.TABLESPACE_NAME) = RTRIM(B.TBSPACE)


aa***@hotmail.com (Amit) wrote in message

news:<85**************************@posting.google. com>...
Not sure if I understand correctly. The last column of the query I
posted showns the partitions that the tablespace exists on. The
tablespace will exist on all partitions of the nodegroup (database
partition group) that its defined on - not just one partition.

Thanks
Amit

Nov 12 '05 #8
Amit,

thanks for your hints, I will give it a try...

regards,
Joachim

"Amit" <aa***@hotmail.com> schrieb im Newsbeitrag
news:85**************************@posting.google.c om...
You will either need to run the Tablespace Snaphot Query separately
(maybe use a sql proc) for each partition (you can pass in the
partition number to the table function) or use recursive sql (using a
common table expression) to call the table function repeatedly with
different partition numbers and show the results with the partition
number as the last column.

"Joachim Mueller" <jom0309@[--spam--]douglas-informatik.de> wrote in

message news:<bu**********@news.dtag.de>...
Amit,

thanks once more, but (a big BUT) sometimes the PERC_USED column is equal on all
partitions, but most the the differ from partition to partition.
What I want is to see which partition have reached the threshold for 85% so I can resize the container
lying on this partition.

Here is a better sample:

TABLESPACE_NAME TBS_TYPE TOTAL_PAGES TOTAL_MB USED_PAGES USED_MB
FREE_PAGES FREE_MB PERC_USED


------------------ -------- ----------- ----------- ----------- ----------

-
----------- ----------- --------------------
USERSPACE DMS 3000000 23437 2382240 18611 617696 4825 79

USERSPACE DMS 3000000 23437 2410496 18832 589440 4605 80

USERSPACE DMS 3000000 23437 2406784 18803 593152 4634 80

USERSPACE DMS 3000000 23437 2421152 18915 578784 4521 80

INDEXSPACE DMS 2560000 20000 2022640 15801 537328 4197 79

INDEXSPACE DMS 2560000 20000 2024432 15815 535536 4183 79

INDEXSPACE DMS 2560000 20000 2014752 15740 545216 4259 78

INDEXSPACE DMS 2560000 20000 2096592 16379 463376 3620 81

You see that USERSPACE also INDEXSPACE have the same TOTAL_PAGES each on one of the four partitions.
But USED_PAGES differs on the four partitions.

Sorry for my bad english, it's hard to explain something thats not my native language;-)

regards,

Joachim

"Amit" <aa***@hotmail.com> schrieb im Newsbeitrag
news:85*************************@posting.google.co m...
oops - realised my query had some problems - here's the one that
calculates the aggregates and returns the total for each tablespace
If you want a query that returns the partition number for each row
instead of aggregate, you can also achive that similarly using sql
recursion (pass in the next node number as the secomd argument in
SNAPSHOT_TBS_CFG ). I think partition number should be in the result
set (and monitor elements) for tablespaces but was proabably left out
due to an oversight.
WITH TEMP1 ( DBPGNAME, DBPARTITIONNUM, ALLNODES, LEVEL) AS ( SELECT
DBPGNAME
,MIN(DBPARTITIONNUM) ,VARCHAR( CHAR(MIN(DBPARTITIONNUM)),50), 0
FROM SYSCAT.DBPARTITIONGROUPDEF A
GROUP BY DBPGNAME UNION ALL
SELECT A.DBPGNAME ,A.DBPARTITIONNUM, (RTRIM(B.ALLNODES) || ', ' ||
CHAR(A.DBPARTITIONNUM)), B.LEVEL+1
FROM SYSCAT.DBPARTITIONGROUPDEF A , TEMP1 B
WHERE A.DBPGNAME = B.DBPGNAME
AND A.DBPARTITIONNUM > B.DBPARTITIONNUM
),
TEMP2 (TBSPACE, DBPGNAME, ALLNODES) AS
( SELECT TBSPACE, F.DBPGNAME, F.ALLNODES FROM SYSCAT.TABLESPACES D
LEFT OUTER JOIN ( SELECT C.DBPGNAME, C.ALLNODES FROM TEMP1 C WHERE
C.LEVEL = ( SELECT MAX(LEVEL) FROM TEMP1 E WHERE
C.DBPGNAME = E.DBPGNAME)) F
ON D.DBPGNAME=F.DBPGNAME ),
TEMP3 (TBSPACE, DBPGNAME, PARTITIONS ) AS
(SELECT TBSPACE, COALESCE( DBPGNAME, 'IBMTEMPGROUP') , COALESCE(
ALLNODES, CHAR((SELECT DBPARTITIONNUM FROM SYSCAT.DBPARTITIONGROUPDEF
WHERE DBPGNAME='IBMCATGROUP' FETCH FIRST ROW ONLY )) ) FROM TEMP2),
TEMP4 AS
(SELECT TABLESPACE_NAME , CASE WHEN TABLESPACE_TYPE = 0 THEN 'DMS'
ELSE 'SMS' END AS
TBS_TYPE, SUM(TOTAL_PAGES) AS TOTAL_PAGES,
SUM(TOTAL_PAGES*PAGE_SIZE)/1024/1024 AS TOTAL_MB, SUM(USED_PAGES) AS
USED_PAGES, SUM(USED_PAGES*PAGE_SIZE)/1024/1024 AS USED_MB,
SUM(FREE_PAGES)
AS FREE_PAGES, SUM(FREE_PAGES*PAGE_SIZE)/1024/1024 AS FREE_MB, CASE
WHEN SUM (TOTAL_PAGES) >0 THEN (SUM(USED_PAGES)
* 100 / SUM (TOTAL_PAGES) ) ELSE NULL END AS PERC_USED FROM TABLE
(SNAPSHOT_TBS_CFG(CAST(NULL AS VARCHAR(20)), -2 )) AS A GROUP BY
TABLESPACE_NAME, TABLESPACE_TYPE )
SELECT A.*, B.DBPGNAME, B.PARTITIONS FROM TEMP4 A INNER JOIN TEMP3 B
ON RTRIM(A.TABLESPACE_NAME) = RTRIM(B.TBSPACE)


aa***@hotmail.com (Amit) wrote in message

news:<85**************************@posting.google. com>...
> Not sure if I understand correctly. The last column of the query I
> posted showns the partitions that the tablespace exists on. The
> tablespace will exist on all partitions of the nodegroup (database
> partition group) that its defined on - not just one partition.
>
> Thanks
> Amit

Nov 12 '05 #9

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

Similar topics

5
by: Yasaswi Pulavarti | last post by:
does a command like, db2 drop table tabschema.tabname when run from the Aix prompt reclaim the disk space? Are there any other options? How can we make sure the disk space is reclaimed? Thanks,...
0
by: Bill Littman | last post by:
We are using a DB2 7.2 system. On the DB2 Control Center of a server, we are viewing the details of the tablespaces. The "percentage used" column is showing a negative value(-69) for one of the...
3
by: Sue | last post by:
Hi, I have a DB2 database with database managed (DMS) tablespaces. One of the tables that I have contains BLOB data. Recently I noticed that 75% of the tablespace for this table was being used up....
3
by: Anurag | last post by:
Hi, I posted this on other user-groups. Hardly got any responses. Here goes the question: PLATFORM = DB2 UDB 8.2+ on AIX 5.x, DPF Two Topics broadly: (A) I wish to find out a rough...
6
by: mike_dba | last post by:
Can anyone tell me why a EEE system might be created to have two separate tablespaces with the same 4k pagesize ? They both appear to be in use as I can see the underlying files being modified. ...
10
by: rAinDeEr | last post by:
Hi, I am trying to create around 70 tablespaces for around 100 tables.. Am using DB2 UDB 8.2 in Linux environment... This is one i generated through Control centre.... CREATE REGULAR...
3
by: dcruncher4 | last post by:
DB2 8.2.3 the task I have is to write a script to restore a database from a backup on to another machine. the backup can be as old as seven years. The container layout on the machine to be...
4
by: Rahul B | last post by:
Hi, How can i find out the space that is currently not utilized/utilized in the tablespace? I tried from syscat.tablespaces, but it doesn't seem to give me that information. Thanks Rahul
6
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
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...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.