diff --git a/modules/paymentreference/paymentreference.install b/modules/paymentreference/paymentreference.install
index 54cfab4..52a0176 100644
--- a/modules/paymentreference/paymentreference.install
+++ b/modules/paymentreference/paymentreference.install
@@ -26,6 +26,11 @@ function paymentreference_schema() {
         'length' => 255,
         'not null' => TRUE,
       ),
+      'instance' => array(
+        'type' => 'varchar',
+        'length' => 255,
+        'not null' => TRUE,
+      ),
       'pid' => array(
         'type' => 'int',
         'not null' => TRUE,
@@ -42,7 +47,7 @@ function paymentreference_schema() {
       ),
     ),
     'indexes' => array(
-      'instance' => array('bundle', 'entity_type', 'field_name'),
+      'instance' => array('instance'),
     ),
   );
 
@@ -89,4 +94,43 @@ function paymentreference_update_7100(&$sandbox) {
       ->condition('pid', $pids)
       ->execute();
   }
-}
\ No newline at end of file
+}
+
+/**
+ * Create a new index on {paymentreference}.
+ */
+function paymentreference_update_7101(array &$sandbox) {
+  $field_definition = array(
+    'type' => 'varchar',
+    'length' => 255,
+    'not null' => FALSE,
+  );
+  if (!array_key_exists('total_items', $sandbox)) {
+    db_add_field('paymentreference', 'instance', $field_definition);
+
+    $query = db_select('paymentreference', 'pr');
+    $query->fields('pr', array('entity_type', 'bundle', 'field_name', 'pid'));
+    $items = $query->execute()->fetchAllAssoc('pid');
+    $sandbox['remaining_items'] = $items;
+    $sandbox['total_items'] = count($sandbox['remaining_items']);
+    if (!$sandbox['total_items']) {
+      return;
+    }
+  }
+  $items_per_run = 100;
+
+  $current_run_items = array_slice($sandbox['remaining_items'], 0, $items_per_run);
+  foreach ($current_run_items as $item) {
+    db_update('paymentreference')->fields(array(
+      'instance' => $item->entity_type . '.' . $item->bundle . '.' . $item->field_name,
+    ))->execute();
+  }
+
+  $sandbox['remaining_items'] = array_slice($sandbox['remaining_items'], $items_per_run);
+  $sandbox['#finished'] = ($sandbox['total_items'] - count($sandbox['remaining_items'])) / $sandbox['total_items'];
+  if ($sandbox['#finished'] == 1) {
+    // Now all rows have been processed, disallow NULL values.
+    $field_definition['not null'] = TRUE;
+    db_change_field('paymentreference', 'instance', 'instance', $field_definition);
+  }
+}
diff --git a/modules/paymentreference/paymentreference.module b/modules/paymentreference/paymentreference.module
index 60154d4..6401510 100644
--- a/modules/paymentreference/paymentreference.module
+++ b/modules/paymentreference/paymentreference.module
@@ -382,6 +382,7 @@ function paymentreference_insert($entity_type, $bundle, $field_name, $pid) {
     'bundle' => $bundle,
     'field_name' => $field_name,
     'pid' => $pid,
+    'instance' => $entity_type . '.' . $bundle . '.' . $field_name,
   );
 
   return drupal_write_record('paymentreference', $data);
@@ -418,9 +419,7 @@ function paymentreference_delete_by_field($field_name) {
  */
 function paymentreference_delete_by_field_instance($entity_type, $bundle, $field_name) {
   db_delete('paymentreference')
-    ->condition('field_name', $field_name)
-    ->condition('entity_type', $entity_type)
-    ->condition('bundle', $bundle)
+    ->condition('instance', $entity_type . '.' . $bundle . '.' . $field_name)
     ->execute();
 }
 
