diff --git a/core/modules/aggregator/aggregator.module b/core/modules/aggregator/aggregator.module
index 06e3cb2..f41c0e3 100644
--- a/core/modules/aggregator/aggregator.module
+++ b/core/modules/aggregator/aggregator.module
@@ -249,10 +249,16 @@ function aggregator_cron() {
   }
 
   // Remove queued timestamp after 6 hours assuming the update has failed.
-  db_update('aggregator_feed')
-    ->fields(array('queued' => 0))
+  $result = \Drupal::entityQuery('aggregator_feed')
     ->condition('queued', REQUEST_TIME - (3600 * 6), '<')
     ->execute();
+  if ($result) {
+    $feeds = entity_load_multiple('aggregator_feed', $result);
+    foreach ($feeds as $feed) {
+      $feed->queued->value = 0;
+      $feed->save();
+    }
+  }
 }
 
 /**
diff --git a/core/modules/aggregator/lib/Drupal/aggregator/Plugin/aggregator/processor/DefaultProcessor.php b/core/modules/aggregator/lib/Drupal/aggregator/Plugin/aggregator/processor/DefaultProcessor.php
index ec7d193..d5c21bb 100644
--- a/core/modules/aggregator/lib/Drupal/aggregator/Plugin/aggregator/processor/DefaultProcessor.php
+++ b/core/modules/aggregator/lib/Drupal/aggregator/Plugin/aggregator/processor/DefaultProcessor.php
@@ -190,9 +190,11 @@ public function process(Feed $feed) {
    * {@inheritdoc}
    */
   public function remove(Feed $feed) {
-    $iids = Database::getConnection()->query('SELECT iid FROM {aggregator_item} WHERE fid = :fid', array(':fid' => $feed->id()))->fetchCol();
-    if ($iids) {
-      entity_delete_multiple('aggregator_item', $iids);
+    $result = \Drupal::entityQuery('aggregator_item')
+      ->condition('fid', $feed->id())
+      ->execute();
+    if ($result) {
+      entity_delete_multiple('aggregator_item', $result);
     }
     // @todo This should be moved out to caller with a different message maybe.
     drupal_set_message(t('The news items from %site have been removed.', array('%site' => $feed->label())));
@@ -209,13 +211,12 @@ public function postProcess(Feed $feed) {
     if ($aggregator_clear != AGGREGATOR_CLEAR_NEVER) {
       // Remove all items that are older than flush item timer.
       $age = REQUEST_TIME - $aggregator_clear;
-      $iids = Database::getConnection()->query('SELECT iid FROM {aggregator_item} WHERE fid = :fid AND timestamp < :timestamp', array(
-        ':fid' => $feed->id(),
-        ':timestamp' => $age,
-      ))
-      ->fetchCol();
-      if ($iids) {
-        entity_delete_multiple('aggregator_item', $iids);
+      $result = \Drupal::entityQuery('aggregator_item')
+        ->condition('fid', $feed->id())
+        ->condition('timestamp', $age, '<')
+        ->execute();
+      if ($result) {
+        entity_delete_multiple('aggregator_item', $result);
       }
     }
   }
