diff --git a/core/modules/node/node.module b/core/modules/node/node.module
index 7c25666..35b8aff 100644
--- a/core/modules/node/node.module
+++ b/core/modules/node/node.module
@@ -3484,6 +3484,10 @@ function node_access_acquire_grants($node, $delete = TRUE) {
  *   some form.
  */
 function _node_access_write_grants($node, $grants, $realm = NULL, $delete = TRUE) {
+  static $saved_grants;
+  if (!isset($saved_grants)) {
+    $saved_grants = array();
+  }
   if ($delete) {
     $query = db_delete('node_access')->condition('nid', $node->nid);
     if ($realm) {
@@ -3502,7 +3506,11 @@ function _node_access_write_grants($node, $grants, $realm = NULL, $delete = TRUE
       // Only write grants; denies are implicit.
       if ($grant['grant_view'] || $grant['grant_update'] || $grant['grant_delete']) {
         $grant['nid'] = $node->nid;
-        $query->values($grant);
+        $grant_string = serialize($grant);
+        if (!in_array($grant_string, $saved_grants)) {
+          $query->values($grant);
+          $saved_grants[] = $grant_string;
+        }
       }
     }
     $query->execute();
