The way I found which works faster when inserting a lot of data in one go needs just a few extras.
- Cache/Serialise the tables to local data structures, if they are read repeatedly and not very large. This can save a lot of SELECT statements generated by LINQ. Preferably, perform a sorting on your local data structure, which can support faster BinarySearch(). (e.g.)
- Write a stored-procedure that handles Bulk-insert to multiple tables, in which you must have safety check and error handling as well. After all, stored procedures are first class citizen in handling the database operations. (e.g.)
- Instead of calling LINQ insert, call the stored procedure (registered as function import in .dbml). (e.g.)
No comments:
Post a Comment