RFE #1548637, option to not display record counts for views
This commit is contained in:
@@ -8,6 +8,9 @@ $HeadURL$
|
||||
2006-12-31 Marc Delisle <lem9@users.sourceforge.net>
|
||||
* Documentation.html: RFE #1602243, another cause for Missing parameter,
|
||||
thanks to Dave Nolan
|
||||
* Documentation.html, db_structure.php, libraries/Table.class.php,
|
||||
/config.default.php: RFE #1548637, MaxExactCountViews (default 0)
|
||||
so by default, row count is not done for views
|
||||
|
||||
2006-12-30 Marc Delisle <lem9@users.sourceforge.net>
|
||||
* libraries/Config.class.php: bug #1590083,
|
||||
|
@@ -1754,16 +1754,18 @@ $cfg['TrustedProxies'] =
|
||||
<dd>Enable <a href="#transformations">MIME-transformations</a>.</dd>
|
||||
|
||||
<dt id="cfg_MaxExactCount">$cfg['MaxExactCount'] integer</dt>
|
||||
<dd><ul><li>For InnoDB tables, determines for how large tables phpMyAdmin
|
||||
<dd>For InnoDB tables, determines for how large tables phpMyAdmin
|
||||
should get the exact row count using <code>SELECT COUNT</code>.
|
||||
If the approximate row count as returned by
|
||||
<code>SHOW TABLE STATUS</code> is smaller than this value,
|
||||
<code>SELECT COUNT</code> will be used, otherwise the approximate
|
||||
count will be used.</li>
|
||||
<li>For VIEWs, since obtaining the exact count could have an
|
||||
impact on performance, this value is the maximum to be displayed.
|
||||
</li>
|
||||
</ul>
|
||||
count will be used.
|
||||
</dd>
|
||||
<dt id="cfg_MaxExactCountViews">$cfg['MaxExactCountViews'] integer</dt>
|
||||
<dd>For VIEWs, since obtaining the exact count could have an
|
||||
impact on performance, this value is the maximum to be displayed, using
|
||||
a <code>SELECT COUNT ... LIMIT</code>. The default value of 0 bypasses
|
||||
any row counting.
|
||||
</dd>
|
||||
|
||||
<dt id="wysiwyg">
|
||||
|
@@ -348,7 +348,7 @@ foreach ($tables as $keyname => $each_table) {
|
||||
// that needs to be repaired
|
||||
|
||||
if (isset($each_table['TABLE_ROWS']) && ($each_table['ENGINE'] != null || $table_is_view)) {
|
||||
if ($table_is_view && $each_table['TABLE_ROWS'] >= $cfg['MaxExactCount']) {
|
||||
if ($table_is_view && $each_table['TABLE_ROWS'] >= $cfg['MaxExactCountViews']) {
|
||||
$at_least_one_view_exceeds_max_count = true;
|
||||
$show_superscript = '<sup>1</sup>';
|
||||
} else {
|
||||
@@ -489,7 +489,7 @@ echo ' <option value="' . $strAnalyzeTable . '" >'
|
||||
|
||||
if ($at_least_one_view_exceeds_max_count && !$db_is_information_schema) {
|
||||
echo '<div class="notice">' . "\n";
|
||||
echo '<sup>1</sup>' . PMA_sanitize(sprintf($strViewMaxExactCount, PMA_formatNumber($cfg['MaxExactCount'], 0), '[a@./Documentation.html#cfg_MaxExactCount@_blank]', '[/a]')) . "\n";
|
||||
echo '<sup>1</sup>' . PMA_sanitize(sprintf($strViewMaxExactCount, PMA_formatNumber($cfg['MaxExactCountViews'], 0), '[a@./Documentation.html#cfg_MaxExactCountViews@_blank]', '[/a]')) . "\n";
|
||||
echo '</div>' . "\n";
|
||||
}
|
||||
?>
|
||||
|
@@ -370,23 +370,34 @@ class PMA_Table {
|
||||
|
||||
$tbl_is_view = PMA_Table::isView($db, $table);
|
||||
|
||||
// for a VIEW, $row_count is always false at this point
|
||||
if (false === $row_count || $row_count < $GLOBALS['cfg']['MaxExactCount']) {
|
||||
if (! $tbl_is_view) {
|
||||
$row_count = PMA_DBI_fetch_value(
|
||||
'SELECT COUNT(*) FROM ' . PMA_backquote($db) . '.'
|
||||
. PMA_backquote($table));
|
||||
// since counting all rows of a view could be too long
|
||||
} else {
|
||||
// try_query because it can fail ( a VIEW was based on
|
||||
// a table that no longer exists)
|
||||
$result = PMA_DBI_try_query(
|
||||
'SELECT 1 FROM ' . PMA_backquote($db) . '.'
|
||||
. PMA_backquote($table) . ' LIMIT '
|
||||
. $GLOBALS['cfg']['MaxExactCount'],
|
||||
null, PMA_DBI_QUERY_STORE);
|
||||
if (!PMA_DBI_getError()) {
|
||||
$row_count = PMA_DBI_num_rows($result);
|
||||
PMA_DBI_free_result($result);
|
||||
// For complex views, even trying to get a partial record
|
||||
// count could bring down a server, so we offer an
|
||||
// alternative: setting MaxExactCountViews to 0 will bypass
|
||||
// completely the record counting for views
|
||||
|
||||
if ($GLOBALS['cfg']['MaxExactCountViews'] == 0) {
|
||||
$row_count = 0;
|
||||
} else {
|
||||
// Counting all rows of a VIEW could be too long, so use
|
||||
// a LIMIT clause.
|
||||
// Use try_query because it can fail ( a VIEW is based on
|
||||
// a table that no longer exists)
|
||||
$result = PMA_DBI_try_query(
|
||||
'SELECT 1 FROM ' . PMA_backquote($db) . '.'
|
||||
. PMA_backquote($table) . ' LIMIT '
|
||||
. $GLOBALS['cfg']['MaxExactCountViews'],
|
||||
null, PMA_DBI_QUERY_STORE);
|
||||
if (!PMA_DBI_getError()) {
|
||||
$row_count = PMA_DBI_num_rows($result);
|
||||
PMA_DBI_free_result($result);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -531,8 +531,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.
|
||||
$cfg['MaxExactCount'] = 20000; // When approximate count < this, PMA will get exact count for table rows.
|
||||
$cfg['MaxExactCountViews'] = 0; // Zero means that no row count is done for views; see the doc
|
||||
$cfg['WYSIWYG-PDF'] = TRUE; // Utilize DHTML/JS capabilities to allow WYSIWYG editing of
|
||||
// the PDF page editor. Requires an IE6/Mozilla based browser.
|
||||
|
||||
|
Reference in New Issue
Block a user