diff --git a/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php b/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php
index 1942f6d..4f0c562 100644
--- a/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php
+++ b/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php
@@ -1600,9 +1600,7 @@ public function countFieldData($storage_definition, $as_bool = FALSE) {
         $or->isNotNull($table_mapping->getFieldColumnName($storage_definition, $column_name));
       }
       $query
-        ->condition($or)
-        ->fields('t', array('entity_id'))
-        ->distinct(TRUE);
+        ->condition($or);
     }
     elseif ($table_mapping->allowsSharedTableStorage($storage_definition)) {
       // Ascertain the table this field is mapped too.
@@ -1623,26 +1621,18 @@ public function countFieldData($storage_definition, $as_bool = FALSE) {
         $or->isNotNull($table_mapping->getFieldColumnName($storage_definition, $property_name));
       }
       $query->condition($or);
-      $query
-        ->fields('t', array($this->idKey))
-        ->distinct(TRUE);
+    }
+    else {
+      $query = $this->database->select($table_name, 't');
     }
 
     // @todo Find a way to count field data also for fields having custom
     //   storage. See https://www.drupal.org/node/2337753.
-    $count = 0;
     if (isset($query)) {
-      // If we are performing the query just to check if the field has data
-      // limit the number of rows.
-      if ($as_bool) {
-        $query->range(0, 1);
-      }
-      else {
-        // Otherwise count the number of rows.
-        $query = $query->countQuery();
-      }
-      $count = $query->execute()->fetchField();
+      $query = $query->countQuery();
     }
+    $count = $query->execute()->fetchField();
+
     return $as_bool ? (bool) $count : (int) $count;
   }
 
