获取 Apache Derby 中 table 使用的 space
Get the space used by a table in Apache Derby
是否可以获取 Apache Derby 中的 table 使用了多少 space?
下面声明returns每个table的大小:
select
tableName,
(select sum(numallocatedpages * pagesize) from new org.apache.derby.diag.SpaceTable('APP', t.tablename) x) as size
from SYS.SYSTABLES t
order by size desc
以下查询显示 space 表和索引的用法。
SELECT
((T2.PAGESIZE * T2.NUMALLOCATEDPAGES) / 1024 / 1024) AS "SIZE IN MB",
T2.*
FROM
SYS.SYSTABLES systabs,
TABLE (SYSCS_DIAG.SPACE_TABLE(systabs.tablename)) AS T2
WHERE systabs.tabletype = 'T'
ORDER by ISINDEX, 1 DESC;
https://db.apache.org/derby/docs/10.7/ref/rrefsyscsdiagtables.html
要删除为非 APP 架构表显示的空大小,请尝试这个基于 Fidels 的修改后的查询。
select
tableName,
(select sum(numallocatedpages * pagesize) from new
org.apache.derby.diag.SpaceTable('APP', t.tablename) x) as size
from SYS.SYSTABLES t
where t.SCHEMAID = (select schemaid from sys.sysschemas where schemaname =
'APP')
order by size desc
是否可以获取 Apache Derby 中的 table 使用了多少 space?
下面声明returns每个table的大小:
select
tableName,
(select sum(numallocatedpages * pagesize) from new org.apache.derby.diag.SpaceTable('APP', t.tablename) x) as size
from SYS.SYSTABLES t
order by size desc
以下查询显示 space 表和索引的用法。
SELECT
((T2.PAGESIZE * T2.NUMALLOCATEDPAGES) / 1024 / 1024) AS "SIZE IN MB",
T2.*
FROM
SYS.SYSTABLES systabs,
TABLE (SYSCS_DIAG.SPACE_TABLE(systabs.tablename)) AS T2
WHERE systabs.tabletype = 'T'
ORDER by ISINDEX, 1 DESC;
https://db.apache.org/derby/docs/10.7/ref/rrefsyscsdiagtables.html
要删除为非 APP 架构表显示的空大小,请尝试这个基于 Fidels 的修改后的查询。
select
tableName,
(select sum(numallocatedpages * pagesize) from new
org.apache.derby.diag.SpaceTable('APP', t.tablename) x) as size
from SYS.SYSTABLES t
where t.SCHEMAID = (select schemaid from sys.sysschemas where schemaname =
'APP')
order by size desc