diff --git a/core/lib/Drupal/Core/Config/Entity/Query/Query.php b/core/lib/Drupal/Core/Config/Entity/Query/Query.php
index b8660aa..033f774 100644
--- a/core/lib/Drupal/Core/Config/Entity/Query/Query.php
+++ b/core/lib/Drupal/Core/Config/Entity/Query/Query.php
@@ -111,6 +111,7 @@ protected function loadRecords() {
 
     // Search the conditions for restrictions on entity IDs.
     $ids = array();
+    $id_condition = NULL;
     if ($this->condition->getConjunction() == 'AND') {
       foreach ($this->condition->conditions() as $condition) {
         if (is_string($condition['field']) && $condition['field'] == $this->entityType->getKey('id')) {
@@ -121,6 +122,9 @@ protected function loadRecords() {
           elseif ($operator == 'IN') {
             $ids = $condition['value'];
           }
+          else {
+            $id_condition = $condition;
+          }
           // We stop at the first restricting condition on ID. In the (weird)
           // case where there are additional restricting conditions, results
           // will be eliminated when the conditions are checked on the loaded
@@ -141,6 +145,41 @@ protected function loadRecords() {
     // If no restrictions on IDs were found, we need to parse all records.
     else {
       $names = $this->configFactory->listAll($prefix);
+      // In case we have an ID condition, try to narrow down the list of config
+      // objects to load.
+      if ($id_condition) {
+        $value = $id_condition['value'];
+        $filter = NULL;
+        switch ($id_condition['operator']) {
+          case '<>':
+            $filter = function ($name) use ($value, $prefix_length) {
+              $id = substr($name, $prefix_length);
+              return $id !== $value;
+            };
+            break;
+          case 'STARTS_WITH':
+            $filter = function ($name) use ($value, $prefix_length) {
+              $id = substr($name, $prefix_length);
+              return strpos($id, $value) === 0;
+            };
+            break;
+          case 'CONTAINS':
+            $filter = function ($name) use ($value, $prefix_length) {
+              $id = substr($name, $prefix_length);
+              return strpos($id, $value) !== FALSE;
+            };
+            break;
+          case 'ENDS_WITH':
+            $filter = function ($name) use ($value, $prefix_length) {
+              $id = substr($name, $prefix_length);
+              return strrpos($id, $value) === strlen($id) - strlen($value);
+            };
+            break;
+        }
+        if ($filter) {
+          $names = array_filter($names, $filter);
+        }
+      }
     }
 
     // Load the corresponding records.
diff --git a/core/modules/system/src/Tests/Entity/ConfigEntityQueryTest.php b/core/modules/system/src/Tests/Entity/ConfigEntityQueryTest.php
index 7641cf2..b049880 100644
--- a/core/modules/system/src/Tests/Entity/ConfigEntityQueryTest.php
+++ b/core/modules/system/src/Tests/Entity/ConfigEntityQueryTest.php
@@ -343,6 +343,62 @@ public function testConfigEntityQuery() {
   }
 
   /**
+   * Tests ID conditions.
+   */
+  public function testStringIdConditions() {
+    // We need an entity with a non-numeric ID.
+    $entity = entity_create('config_query_test', array(
+      'label' => $this->randomMachineName(),
+      'id' => 'foo.bar',
+    ));
+    $this->entities[] = $entity;
+    $entity->enforceIsNew();
+    $entity->save();
+
+    // Test 'STARTS_WITH' condition.
+    $this->queryResults = $this->factory->get('config_query_test')
+      ->condition('id', 'foo.bar', 'STARTS_WITH')
+      ->execute();
+    $this->assertResults(array('foo.bar'));
+    $this->queryResults = $this->factory->get('config_query_test')
+      ->condition('id', 'f', 'STARTS_WITH')
+      ->execute();
+    $this->assertResults(array('foo.bar'));
+    $this->queryResults = $this->factory->get('config_query_test')
+      ->condition('id', 'miss', 'STARTS_WITH')
+      ->execute();
+    $this->assertResults(array());
+
+    // Test 'CONTAINS' condition.
+    $this->queryResults = $this->factory->get('config_query_test')
+      ->condition('id', 'foo.bar', 'CONTAINS')
+      ->execute();
+    $this->assertResults(array('foo.bar'));
+    $this->queryResults = $this->factory->get('config_query_test')
+      ->condition('id', 'oo.ba', 'CONTAINS')
+      ->execute();
+    $this->assertResults(array('foo.bar'));
+    $this->queryResults = $this->factory->get('config_query_test')
+      ->condition('id', 'miss', 'CONTAINS')
+      ->execute();
+    $this->assertResults(array());
+
+    // Test 'ENDS_WITH' condition.
+    $this->queryResults = $this->factory->get('config_query_test')
+      ->condition('id', 'foo.bar', 'ENDS_WITH')
+      ->execute();
+    $this->assertResults(array('foo.bar'));
+    $this->queryResults = $this->factory->get('config_query_test')
+      ->condition('id', 'r', 'ENDS_WITH')
+      ->execute();
+    $this->assertResults(array('foo.bar'));
+    $this->queryResults = $this->factory->get('config_query_test')
+      ->condition('id', 'miss', 'ENDS_WITH')
+      ->execute();
+    $this->assertResults(array());
+  }
+
+  /**
    * Tests count query.
    */
   public function testCount() {
