Issue #2388765 by alexpott: Improve performance of SqlContentEntityStorage::countFieldData() for large datasets when getting the result as a boolean

8.0.x
Nathaniel Catchpole 2014-12-09 16:03:20 +00:00
parent 82989783cc
commit d3e81f5e0d
1 changed files with 5 additions and 1 deletions

View File

@ -1759,7 +1759,11 @@ class SqlContentEntityStorage extends ContentEntityStorageBase implements SqlEnt
if ($as_bool) {
$query->range(0, 1);
}
$count = $query->countQuery()->execute()->fetchField();
else {
// Otherwise count the number of rows.
$query = $query->countQuery();
}
$count = $query->execute()->fetchField();
}
return $as_bool ? (bool) $count : (int) $count;
}