Counting total records of multiple tables

Discussion in 'Databases' started by itssangy, Aug 23, 2007.

  1. #1
    Hello,

    I have a database with 30 tables, I would like to count the total number of records with the shortest # of queries. I can count them by select count(*) from individual table and add them up but that would take too many queries. Is there a faster way out there?

    thanks
     
    itssangy, Aug 23, 2007 IP
  2. Clark Kent

    Clark Kent Guest

    Messages:
    122
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #2
    <?php

    mysql_connect("localhost","root","");
    $result = mysql_query("SHOW TABLE STATUS FROM test;");
    while($array = mysql_fetch_array($result)) {
    $total = $array[Data_length]+$array[Index_length];
    echo '
    Table: '.$array[Name].'<br />
    Data Size: '.$array[Data_length].'<br />
    Index Size: '.$array[Index_length].'<br />
    Total Size: '.$total.'<br />
    Total Rows: '.$array[Rows].'<br />
    Average Size Per Row: '.$array[Avg_row_length].'<br /><br />
    ';
    }

    ?>
     
    Clark Kent, Aug 23, 2007 IP
  3. itssangy

    itssangy Peon

    Messages:
    135
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #3
    works like a charm!

    thanks superman
     
    itssangy, Aug 23, 2007 IP