Quickly update a large amount of rows in a table, without blocking inserts on referencing tables, in SQL Server 2008 -


context: have system acts web ui legacy accounting system. legacy system sends me large text file, several times day, can update contract table in database (the file can have new contracts, or updated values existing contracts). table has around 2m rows , 150 columns. can't have downtime during these updates, since happen during day , there's 40 logged users in given time.

my system's users can't update contract table, can insert records in tables reference contract table (foreign keys contract table's id column).

to update contract table first load text file staging table, using bulk insert, , use merge statement create or update rows, in batches of 100k records. , here's problem - during merge statement, because i'm using read commited snapshot isolation, users can keep viewing data, can't insert - transactions timeout because contract table locked.

question: know of way update large amount of rows, while enforcing data integrity , without blocking inserts on referencing tables?

i've thought few workarounds, i'm hoping there's better way:

  1. drop foreign keys. - i'd enforce data consistency, don't sound solution.
  2. decrease batch size on merge statement transaction fast enough not cause timeouts on other transactions. - have tried this, sync process becomes slow; has mentioned above, receive update files , it's vital updated data available shortly after.
  3. create intermediate table, single contractid column , have other tables reference table, instead of contract table. allow me update faster while keeping decent integrity. - guess work, sounds convoluted.

update: ended dropping foreign keys. since system has been in production time , logs don't ever show foreign key constraint violations, i'm pretty sure no inconsistent data created. commented.


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -