Skip to content

Commit

Permalink
database: Optimizer for Large database
Browse files Browse the repository at this point in the history
  • Loading branch information
vuthao committed May 23, 2016
1 parent b0551fb commit d822175
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions admin/database/functions.php
Expand Up @@ -43,12 +43,23 @@ function nv_show_tables()
$tables_size = floatval($item['data_length']) + floatval($item['index_length']);

if ($item['engine'] != 'MyISAM') {
$item['rows'] = $db->query("SELECT COUNT(*) FROM " . $item['name'])->fetchColumn();
if($item['rows'] < 100000)
{
$item['rows'] = $db->query("SELECT COUNT(*) FROM " . $item['name'])->fetchColumn();
$item['rows'] = number_format($item['rows']);
}
else {
$item['rows'] = '~' . number_format($item['rows']);
}
}
else
{
$item['rows'] = number_format($item['rows']);
}
$tables[$item['name']]['table_size'] = nv_convertfromBytes($tables_size);
$tables[$item['name']]['table_max_size'] = ! empty($item['max_data_length']) ? nv_convertfromBytes(floatval($item['max_data_length'])) : 0;
$tables[$item['name']]['table_datafree'] = ! empty($item['data_free']) ? nv_convertfromBytes(floatval($item['data_free'])) : 0;
$tables[$item['name']]['table_numrow'] = intval($item['rows']);
$tables[$item['name']]['table_numrow'] = $item['rows'];
$tables[$item['name']]['table_charset'] = (! empty($item['collation']) && preg_match('/^([a-z0-9]+)_/i', $item['collation'], $m)) ? $m[1] : '';
$tables[$item['name']]['table_type'] = (isset($item['engine'])) ? $item['engine'] : $item['type'];
$tables[$item['name']]['table_auto_increment'] = (isset($item['auto_increment'])) ? intval($item['auto_increment']) : 'n/a';
Expand Down

0 comments on commit d822175

Please sign in to comment.