ofcoursedude
ofcoursedude

Reputation: 456

Parallel updates in one script

I have a script that, at some point, updates several large tables. The tables are independent of each other, have 40+mil rows and each row is updated by resetting an integer value. Something like:

update table table_with_40_mil_rows set integer_column=1

update table table_with_70_mil_rows set integer_column=1

etc.

Processing of each such statement takes between 8 and 15 minutes.

Is there a way to run 2 or more of these table updates in parallel? The disks are pretty fast and 8+ cores are available.

Thanks

Upvotes: 1

Views: 106

Answers (2)

Alexander Volok
Alexander Volok

Reputation: 5940

Vanilla T-SQL will not give so much possibilities to run few updates in parallel. As exceptions - asynchronous service broker, but it is advanced topic.

The more or less easy ways:

  • SSIS package that executes few T-SQL tasks in parallel
  • Few SQL Agent Jobs that triggered by one master job at the same time
  • Few SSMS windows that run queries in parallel

Upvotes: 1

Tab Alleman
Tab Alleman

Reputation: 31785

Not as long as they are in a single script running on the same connection. SQL Server cannot be made to process a single script in an asynchronous, threaded fashion. At least not in TSQL. Maybe in a CLR procedure.

Upvotes: 1

Related Questions