summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathaniel Catchpole2014-12-09 16:03:20 (GMT)
committerNathaniel Catchpole2014-12-09 16:03:20 (GMT)
commitd3e81f5e0dcdb978207633de757582b41b3206ac (patch)
tree1c1dc263206c05191c86e83be12e849f552e432b
parent82989783cc3329259986cdf6f7885cde1d6027c0 (diff)
Issue #2388765 by alexpott: Improve performance of SqlContentEntityStorage::countFieldData() for large datasets when getting the result as a boolean
-rw-r--r--core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php6
1 files changed, 5 insertions, 1 deletions
diff --git a/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php b/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php
index d46c37e..40a695e 100644
--- a/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php
+++ b/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php
@@ -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;
}