I have a table structure which basically looks like this:
UserItems <= Users => UserTransactions
The UserItems and USerTransactions tables contain UserId FK in both of them which are indexed.
The two of these tables both contain millions and millions of recods ( last time I checked UserTransactions it had around 14 million records).
I'm facing a huge performace issue and slowdown when trying to perform an insert into either of these tables.
My code for insert looks like this:
using (var ctx = new mydbEntities())
{
ctx.Configuration.AutoDetectChangesEnabled = false;
ctx.Configuration.ValidateOnSaveEnabled = false;
_listOfUserTransactions; // List<UserTransactions>
ctx.BulkInsert(_listOfUserTransactions);
ctx.SaveChanges();
}
Let's suppose that _listOfUserTransactions contians 100k entities in itself. Before the tables had smaller amounts of records, the insert was performing blazingly fast... Now it's become very very slow and inserting 100k records with BulkInsert now sometimes takes several hours...
I have no idea anymore what to do to improve the insert performance...
Can you guys help me out ??