diff --git a/ChangeLog b/ChangeLog index 180ccdf43..7c6c01518 100755 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,12 @@ phpMyAdmin - Changelog $Id$ $Source$ +2003-04-11 Michal Cihar + * db_details_structure.php3: Get row count by SHOW TABLE STATUS, and by + SELECT COUNT(*) only for small (<20000 rows) tables (RFE #708533). + * config.inc.php3, db_details_structure.php3, libraries/common.lib.php3: + $cfg['MaxExactCount'] is now used instead of hardcoded 20000 for above. + 2003-04-10 Michal Cihar * pdf_schema.php3, libraries/common.lib.php3, libraries/display_tbl.lib.php3, libraries/get_foreign.lib.php3: Get row diff --git a/config.inc.php3 b/config.inc.php3 index 2d78d72b6..f95cece53 100755 --- a/config.inc.php3 +++ b/config.inc.php3 @@ -412,6 +412,8 @@ $cfg['QueryWindowDefTab'] = 'sql'; // which tab to display in the query $cfg['QueryHistoryMax'] = 25; // When using DB-based query history, how many entries // should be kept? $cfg['BrowseMIME'] = TRUE; // Use MIME-Types (stored in column comments table) for +$cfg['MaxExactCount'] = 20000; // When approximate count < this, PMA will get exact count for + // table rows. /** * SQL Query box settings diff --git a/db_details_structure.php3 b/db_details_structure.php3 index 1e9ecf37f..b81203b67 100644 --- a/db_details_structure.php3 +++ b/db_details_structure.php3 @@ -240,13 +240,17 @@ else if (PMA_MYSQL_INT_VERSION >= 32303) { } //$display_rows = ' - '; // get row count with another method - $local_query = 'SELECT COUNT(*) AS count FROM ' - . PMA_backquote($db) . '.' - . PMA_backquote($table); - $table_info_result = PMA_mysql_query($local_query) - or PMA_mysqlDie('', $local_query, '', $err_url_0); - $row_count = PMA_mysql_result($table_info_result, 0, 'count'); - $sum_entries += $row_count; + if ($sts_data['Rows'] < $cfg['MaxExactCount']) { + $local_query = 'SELECT COUNT(*) AS count FROM ' + . PMA_backquote($db) . '.' + . PMA_backquote($table); + $table_info_result = PMA_mysql_query($local_query) + or PMA_mysqlDie('', $local_query, '', $err_url_0); + $row_count = PMA_mysql_result($table_info_result, 0, 'count'); + $sum_entries += $row_count; + } else { + $sum_entries += $sts_data['Rows']; + } $display_rows = number_format($row_count, 0, $number_decimal_separator, $number_thousands_separator); } diff --git a/libraries/common.lib.php3 b/libraries/common.lib.php3 index 3b0a41c5f..0c092f985 100644 --- a/libraries/common.lib.php3 +++ b/libraries/common.lib.php3 @@ -1224,13 +1224,13 @@ h1 {font-family: sans-serif; font-size: large; font-weight: bold} */ function PMA_countRecords($db, $table, $ret = FALSE) { - global $err_url; + global $err_url, $cfg; if (PMA_MYSQL_INT_VERSION >= 32303) { $local_query = 'SHOW TABLE STATUS LIKE \'' . PMA_sqlAddslashes($table, TRUE) . '\' FROM \'' . PMA_sqlAddslashes($table, TRUE) . '\''; $result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url); $showtable = PMA_mysql_fetch_array($result); $num = (isset($showtable['Rows']) ? $showtable['Rows'] : 0); - if ($num < 20000) unset($num); + if ($num < $cfg['MaxExactCount']) unset($num); mysql_free_result($result); } if (!isset($num)) {