回答之前的披露:我和JawsDB 🙂
Jaws根据information_schema通过将该数据库中每个表的data_length和index_length值相加来计算已用空间.
像下面这样的查询用于执行此操作.
select
s.schema_name
,sp.grantee user
,cast(round(sum(coalesce(t.data_length + t.index_length, 0)) / 1024 / 1024, 3) as char) db_size_mb
,sp.has_insert
from
information_schema.schemata s
inner join
information_schema.tables t on s.schema_name = t.table_schema
inner join (
select
spi.grantee
,spi.table_schema
,max(
case
when spi.privilege_type = 'INSERT' then 1
else 0
end
) has_insert
from
information_schema.schema_privileges spi
group by
spi.grantee
,spi.table_schema
) sp on s.schema_name = sp.table_schema
group by
s.schema_name;
如果数据库表的大小超过授予用户计划的大小,则会暂时撤消INSERT权限,直到数据库大小恢复为符合计划.这可以通过删除旧数据或升级其计划来完成.