Skip to content

Commit

Permalink
Tweak to main getData query so it doesn't use SQL_CALC_FOUND_ROWS if we
Browse files Browse the repository at this point in the history
are merging joins, as in that case we never use COUNT FOUND(), and in
certain cases using it can greatly increase the main SELECT query time.
  • Loading branch information
cheesegrits committed May 13, 2013
1 parent ee3025c commit 5bd4a0b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,4 @@ libraries/dompdf/lib/fonts/log.htm
libraries/dompdf/lib/fonts/dompdf_font_family_cache.dist.php
/t3-assets
/joomlatools-files
/.externalToolBuilders
9 changes: 7 additions & 2 deletions components/com_fabrik/models/list.php
Original file line number Diff line number Diff line change
Expand Up @@ -2314,16 +2314,21 @@ function _buildQuerySelect($mode = 'list')
JDEBUG ? $profiler->mark('queryselect: fields loaded') : null;
$sfields = (empty($fields)) ? '' : implode(", \n ", $fields) . "\n ";

/**
* Testing potential fix for FOUND_ROWS performance issue on large tables. If merging,
* we never do a SELECT FOUND_ROWS(), so no need to use SQL_CALC_FOUND_ROWS.
*/
$calc_found_rows = $this->mergeJoinedData() ? '' : 'SQL_CALC_FOUND_ROWS';
// $$$rob added raw as an option to fix issue in saving calendar data
if (trim($table->db_primary_key) != '' && (in_array($this->outPutFormat, array('raw', 'html', 'feed', 'pdf', 'phocapdf', 'csv'))))
{
$sfields .= ', ';
$strPKey = $pk . ' AS ' . $db->quoteName('__pk_val') . "\n";
$query = 'SELECT SQL_CALC_FOUND_ROWS DISTINCT ' . $sfields . $strPKey;
$query = 'SELECT ' . $calc_found_rows . ' DISTINCT ' . $sfields . $strPKey;
}
else
{
$query = 'SELECT SQL_CALC_FOUND_ROWS DISTINCT ' . trim($sfields, ", \n") . "\n";
$query = 'SELECT ' . $calc_found_rows . ' DISTINCT ' . trim($sfields, ", \n") . "\n";
}
$query .= ' FROM ' . $db->quoteName($table->db_table_name) . " \n";
return $query;
Expand Down

0 comments on commit 5bd4a0b

Please sign in to comment.