diff --git a/relation.module b/relation.module
index e9772b0..b1f9bcc 100644
--- a/relation.module
+++ b/relation.module
@@ -427,34 +427,41 @@ function relation_entity_delete(Drupal\Core\Entity\EntityInterface $entity) {
     relation_clear_related_entities_cache($entity->endpoints);
   }
 
-  // Delete relations to this entity.
-  $relation_ids = relation_query($entity->getEntityTypeId(), $entity->id())->execute();
-  // IDs of relations to delete.
-  $relations_to_delete = array();
-  foreach (entity_load_multiple('relation', $relation_ids) as $relation) {
-    // Remove any endpoints pointing to entity`
-    foreach ($relation->endpoints as $key => $endpoint) {
-      if ($endpoint->entity_id == $entity->id() && $endpoint->entity_type == $entity->getEntityTypeId()) {
-        unset($relation->endpoints[$key]);
+  // Check if there is any relation.
+  $relations_exist = \Drupal::entityTypeManager()->getStorage('relation')->getQuery()
+    ->range(0, 1)
+    ->execute();
+  if ($relations_exist) {
+    // Delete relations to this entity.
+    $relation_ids = relation_query($entity->getEntityTypeId(), $entity->id())->execute();
+    // IDs of relations to delete.
+    $relations_to_delete = array();
+    foreach (entity_load_multiple('relation', $relation_ids) as $relation) {
+      // Remove any endpoints pointing to entity`
+      foreach ($relation->endpoints as $key => $endpoint) {
+        if ($endpoint->entity_id == $entity->id() && $endpoint->entity_type == $entity->getEntityTypeId()) {
+          unset($relation->endpoints[$key]);
+        }
       }
-    }
 
-    // Check if relation remains valid with regards to arity.
-    $relation_type = entity_load('relation_type', $relation->bundle());
-    $arity = count($relation->endpoints);
-    if ($relation_type && ($arity < $relation_type->min_arity)) {
-      // Not valid - delete.
-      array_push($relations_to_delete, $relation->id());
+      // Check if relation remains valid with regards to arity.
+      $relation_type = entity_load('relation_type', $relation->bundle());
+      $arity         = count($relation->endpoints);
+      if ($relation_type && ($arity < $relation_type->min_arity)) {
+        // Not valid - delete.
+        array_push($relations_to_delete, $relation->id());
+      }
+      else {
+        // Valid - save.
+        $relation->save();
+      }
     }
-    else {
-      // Valid - save.
-      $relation->save();
+    if (!empty($relations_to_delete)) {
+      entity_delete_multiple('relation', $relations_to_delete);
+      \Drupal::logger('relation')
+             ->error('Relations @relations have been deleted.', array('@relations' => implode(', ', $relations_to_delete)));
     }
   }
-  if (!empty($relations_to_delete)) {
-    entity_delete_multiple('relation', $relations_to_delete);
-    \Drupal::logger('relation')->error('Relations @relations have been deleted.', array('@relations' => implode(', ', $relations_to_delete)));
-  }
 }
 
 /**
