Permalink
Browse files

Optimizing deletes, will only apply for indexes that are active

  • Loading branch information...
1 parent c838a9e commit b12ecef004e181fe00fdfe5b8ca60da13550983e @ayende ayende committed Oct 26, 2011
Showing with 14 additions and 0 deletions.
  1. +14 −0 Raven.Database/DocumentDatabase.cs
@@ -534,6 +534,20 @@ public bool Delete(string key, Guid? etag, TransactionInformation transactionInf
deleted = true;
foreach (var indexName in IndexDefinitionStorage.IndexNames)
{
+ AbstractViewGenerator abstractViewGenerator = IndexDefinitionStorage.GetViewGenerator(indexName);
+ if(abstractViewGenerator == null)
+ continue;
+
+ var token = metadata.Value<string>(Constants.RavenEntityName);
+
+ if (token != null && // the document has a entity name
+ abstractViewGenerator.ForEntityNames.Count > 0) // the index operations on specific entities
+ {
+ if(abstractViewGenerator.ForEntityNames.Contains(token) == false)
+ continue;
+ }
+
+
var task = ((Func<Task>) (() => new RemoveFromIndexTask { Keys = { key } }))();
task.Index = indexName;
actions.Tasks.AddTask(task, SystemTime.UtcNow);

0 comments on commit b12ecef

Please sign in to comment.