mysql index and data file?

kaits

Mitglied
hi

is it possible to get from some database the size of index file and data file? in bytes or something?

and how to find out when i have to optimize some databases and when not?

all answers are welcome :)
and feel free to answer in german ;)
 
Mh..

in one of my pages, there's a script which tells me the whole size of the DB with all tables. The script goes like this:
PHP:
<?
include("connect.inc.php");
error_reporting(7);

$memory = 0;

// get tables
$result = mysql_query("SHOW TABLES FROM $db_name");
while($row = mysql_fetch_array($result)) 
{
   $result2=mysql_query("SHOW TABLE STATUS FROM $db_name LIKE '$row[0]'");
   $data=mysql_fetch_array($result2);

   $memory += round(($data['Index_length'] +  $data['Data_length'])/1024 ,2);
}

echo number_format($memory,2,",",".")." KB<br>";
?>
I think you know you have to optimize your database when there's no more space left ;)

There is another possibility too. If u're using phpmyadmin there is a way to optimize your database or one of the included tables. Click on one of your tables to get a detailed view of it. If there is something neccessary to optimize it will be shown in a special link which should be called "Optimize Tables". This happens in case that you have deleted something. I am not sure about if this is in every phpmyadmin version. I am using phpMyAdmin 2.2.0rc4, so if you dont find it you maybe have to update your's.

Hope I could help and you were able to understand my horrible english :D

bye
 
Zurück