Get row count by SHOW TABLE STATUS, and by SELECT COUNT(*) only for small (<20000 rows) tables (RFE #708533).
This commit is contained in:
@@ -5,6 +5,12 @@ phpMyAdmin - Changelog
|
||||
$Id$
|
||||
$Source$
|
||||
|
||||
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
|
||||
count by SHOW TABLE STATUS, and by SELECT COUNT(*) only for small
|
||||
(<20000 rows) tables (RFE #708533).
|
||||
|
||||
2003-04-09 Michal Cihar <nijel@users.sourceforge.net>
|
||||
* libraries/build_dump.lib.php3: Fixed undefined index warnings in LaTeX
|
||||
and XML dump.
|
||||
|
@@ -1224,9 +1224,20 @@ h1 {font-family: sans-serif; font-size: large; font-weight: bold}
|
||||
*/
|
||||
function PMA_countRecords($db, $table, $ret = FALSE)
|
||||
{
|
||||
$result = PMA_mysql_query('SELECT COUNT(*) AS num FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table));
|
||||
$num = ($result) ? PMA_mysql_result($result, 0, 'num') : 0;
|
||||
mysql_free_result($result);
|
||||
global $err_url;
|
||||
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);
|
||||
mysql_free_result($result);
|
||||
}
|
||||
if (!isset($num)) {
|
||||
$result = PMA_mysql_query('SELECT COUNT(*) AS num FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table)) or PMA_mysqlDie('', $local_query, '', $err_url);
|
||||
$num = ($result) ? PMA_mysql_result($result, 0, 'num') : 0;
|
||||
mysql_free_result($result);
|
||||
}
|
||||
if ($ret) {
|
||||
return $num;
|
||||
} else {
|
||||
|
@@ -156,10 +156,7 @@ if (!defined('PMA_DISPLAY_TBL_LIB_INCLUDED')) {
|
||||
}
|
||||
else if (($do_display['nav_bar'] == '1' || $do_display['sort_lnk'] == '1')
|
||||
&& (!empty($db) && !empty($table))) {
|
||||
$local_query = 'SELECT COUNT(*) AS total FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table);
|
||||
$result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url);
|
||||
$the_total = PMA_mysql_result($result, 0, 'total');
|
||||
mysql_free_result($result);
|
||||
$the_total = PMA_countRecords($db, $table, TRUE);
|
||||
}
|
||||
|
||||
// 4. If navigation bar or sorting fields names urls should be
|
||||
|
@@ -27,10 +27,7 @@
|
||||
// We could also do the SELECT anyway, with a LIMIT, and ensure that
|
||||
// the current value of the field is one of the choices.
|
||||
|
||||
$count_query = 'SELECT COUNT(*) AS total FROM ' . PMA_backquote($foreign_db) . '.' . PMA_backquote($foreign_table);
|
||||
$count_result = PMA_mysql_query($count_query) or PMA_mysqlDie('', $count_query, '', $err_url);
|
||||
$the_total = PMA_mysql_result($count_result, 0, 'total');
|
||||
mysql_free_result($count_result);
|
||||
$the_total = PMA_countRecords($db, $table, TRUE);
|
||||
|
||||
if ($the_total < 200) {
|
||||
// foreign_display can be FALSE if no display field defined:
|
||||
|
@@ -1295,10 +1295,8 @@ function PMA_RT_DOC($alltables ){
|
||||
$update_time = (isset($showtable['Update_time']) ? PMA_localisedDate(strtotime($showtable['Update_time'])) : '');
|
||||
$check_time = (isset($showtable['Check_time']) ? PMA_localisedDate(strtotime($showtable['Check_time'])) : '');
|
||||
} else {
|
||||
$local_query = 'SELECT COUNT(*) AS count FROM ' . PMA_backquote($table);
|
||||
$result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url);
|
||||
$showtable = array();
|
||||
$num_rows = PMA_mysql_result($result, 0, 'count');
|
||||
$num_rows = PMA_countRecords($db, $table, TRUE);
|
||||
$show_comment = '';
|
||||
$create_time = '';
|
||||
$update_time = '';
|
||||
|
Reference in New Issue
Block a user