简单记录一下,因为看了一下Data free的计算还算准确。不是统计值
大概是空闲extent的大小。
ST_FIELD_INFO tables_fields_info[]= {... {"DATA_FREE",
MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, (MY_I_S_MAYBE_NULL |
MY_I_S_UNSIGNED), "Data_free", OPEN_FULL_TABLE}, ... }
tables_fields_info[12]就是Data_free ST_SCHEMA_TABLE schema_tables[]= {...
{"TABLES", tables_fields_info, create_schema_table, get_all_tables,
make_old_format, get_schema_tables_record, 1, 2, 0, OPTIMIZE_I_S_TABLE}, ... }
填充方式get_schema_tables_record函数 其中有一句 table->field[12]->store((longlong)
file->stats.delete_length, TRUE); 实际就是 file->stats.delete_length
其中 file->stats.delete_length调用进行取值
ha_innobase::info_low 其中包含 avail_space =
fsp_get_available_space_in_free_extents(ib_table->space); stats.delete_length =
avail_space * 1024; uintmax_t fsp_get_available_space_in_free_extents( const
fil_space_t* space) { ut_ad(space->n_pending_ops > 0); ulint size_in_header =
space->size_in_header;//总的页面大小 if (size_in_header < FSP_EXTENT_SIZE) { //碎片页
直接返回0 return(0); /* TODO: count free frag pages and return a value based on
that */ } /* Below we play safe when counting free extents above the free
limit: some of them will contain extent descriptor pages, and therefore will
not be free extents */ ut_ad(size_in_header >= space->free_limit); ulint
n_free_up = (size_in_header - space->free_limit) / FSP_EXTENT_SIZE;
//(总的页面大小-已经初始化大小)/EXTENT SIZE page_size_t page_size(space->flags); if
(n_free_up > 0) { n_free_up--; n_free_up -= n_free_up / (page_size.physical() /
FSP_EXTENT_SIZE); //减去extent管理块? } /* We reserve 1 extent + 0.5 % of the space
size to undo logs and 1 extent + 0.5 % to cleaning operations; NOTE: this
source code is duplicated in the function above! */ ulint reserve = 2 +
((size_in_header / FSP_EXTENT_SIZE) * 2) / 200; ulint n_free = space->free_len
+ n_free_up; if (reserve > n_free) { return(0); }
return(static_cast<uintmax_t>(n_free - reserve) * FSP_EXTENT_SIZE *
(page_size.physical() / 1024)); }
作者微信:gp_22389860

友情链接
KaDraw流程图
API参考文档
OK工具箱
云服务器优惠
阿里云优惠券
腾讯云优惠券
华为云优惠券
站点信息
问题反馈
邮箱:[email protected]
QQ群:637538335
关注微信