SHOW TABLE STATUS / SELECT COUNT (*) fixes continues, now configurable
This commit is contained in:
@@ -5,6 +5,12 @@ phpMyAdmin - Changelog
|
||||
$Id$
|
||||
$Source$
|
||||
|
||||
2003-04-11 Michal Cihar <nijel@users.sourceforge.net>
|
||||
* 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 <nijel@users.sourceforge.net>
|
||||
* pdf_schema.php3, libraries/common.lib.php3,
|
||||
libraries/display_tbl.lib.php3, libraries/get_foreign.lib.php3: Get row
|
||||
|
@@ -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
|
||||
|
@@ -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);
|
||||
}
|
||||
|
||||
|
@@ -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)) {
|
||||
|
Reference in New Issue
Block a user