468,140 Members | 1,425 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,140 developers. It's quick & easy.

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 2296
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Yasaswi Pulavarti | last post: by
3 posts views Thread by Sue | last post: by
3 posts views Thread by Anurag | last post: by
10 posts views Thread by rAinDeEr | last post: by
3 posts views Thread by dcruncher4 | last post: by
4 posts views Thread by Rahul B | last post: by
1 post views Thread by gcdp | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.