// increase this number a lot to avoid making too many queries
// LIMIT is not much faster than a no LIMIT query
// CRM-7675
- const EXPORT_ROW_COUNT = 10000;
+ const EXPORT_ROW_COUNT = 100000;
/**
* Get Querymode based on ExportMode
// for CRM-3157 purposes
$i18n = CRM_Core_I18n::singleton();
+
list($outputColumns, $headerRows, $sqlColumns, $metadata) = self::getExportStructureArrays($returnProperties, $query, $phoneTypes, $imProviders, $contactRelationshipTypes, $relationQuery, $selectedPaymentFields);
- while (1) {
+ $limitReached = FALSE;
+ while (!$limitReached) {
$limitQuery = "{$queryString} LIMIT {$offset}, {$rowCount}";
- $dao = CRM_Core_DAO::executeQuery($limitQuery);
- if ($dao->N <= 0) {
- break;
- }
+ $dao = CRM_Core_DAO::executeUnbufferedQuery($limitQuery);
+ // If this is less than our limit by the end of the iteration we do not need to run the query again to
+ // check if some remain.
+ $rowsThisIteration = 0;
while ($dao->fetch()) {
$count++;
+ $rowsThisIteration++;
$row = array();
//convert the pseudo constants
}
}
$dao->free();
+ if ($rowsThisIteration < self::EXPORT_ROW_COUNT) {
+ $limitReached = TRUE;
+ }
$offset += $rowCount;
}