Saving Error When Index Is Disabled

Posts   
 
    
JoshWright
User
Posts: 12
Joined: 05-Sep-2008
# Posted on: 18-Jan-2013 15:43:00   

I'm using LLBLGen 3.1, Self Servicing to migrate data to a new system. There are millions of rows & at the current rate it will take weeks to move the data. We move entities in batches of ~200 and I've noticed that the batches start out very fast and get dramatically slower. I'm guessing I need to turn off indexes temporarily.

So I turned off an index for a table 'Message':

alter index PK__Message__36B12243 on [MESSAGE] disable

but when I save I get this error:

An exception was caught during the execution of an action query: The query processor is unable to produce a plan because the index 'PK__Message__36B12243' on table or view 'Message' is disabled.. Check InnerException, QueryExecuted and Parameters of this exception to examine the cause of this exception.

Then I figured that LLBLGen is refetching after the save, so I tried three different things:


EntityBase.MarkSavedEntitiesAsFetched = true;

<add key="markSavedEntitiesAsFetched" value="true"/>

newMessage.Fields.State = EntityState.Fetched;

None of it prevented the exception. Am I thinking of this wrong? My code basically looks like this:


var newMessages = new New_MessageCollection();
for(var oldMessage in oldMessages)
{
    var newMessage = new New_MessageEntity();
    newMessage.Id = GuidComb.NewGuid();
    newMessage.LegacyId = oldMessage.MessageId;
    newMessage.Subject = oldMessage.Subject;
    newMessage.Body = oldMessage.ParseBody();
    newMessages.Add(newMessage);
}
newMessages.Save(false);

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 19-Jan-2013 00:34:40   

In SelfServicing, it has to do a refetch, specially for the newly PK. It is the way SelfServicing works. In Adapter you have more control on this.

Also, we really don't recommend using LLBLGen for migration purposes, as it's not designed for that. It's not that LLBLGen is slow, but there are other faster ways/tools that work directly on the DB.

David Elizondo | LLBLGen Support Team