Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 231957
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T19:58:36+00:00 2026-05-11T19:58:36+00:00

Recently I had to deal with a problem that I imagined would be pretty

  • 0

Recently I had to deal with a problem that I imagined would be pretty common: given a database table with a large (million+) number of rows to be processed, and various processors running in various machines / threads, how to safely allow each processor instance to get a chunk of work (say 100 items) without interfering with one another?

The reason I am getting a chunk at a time is for performance reasons – I don’t want to go to the database for each item.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T19:58:36+00:00Added an answer on May 11, 2026 at 7:58 pm

    There are a few approaches – you could associate each processor a token, and have a SPROC that sets that token against the next [n] available items; perhaps something like:

    (note – needs suitable isolation-level; perhaps serializable: SET TRANSACTION ISOLATION LEVEL SERIALIZABLE)

    (edited to fix TSQL)

    UPDATE TOP (1000) WORK
    SET [Owner] = @processor, Expiry = @expiry
    OUTPUT INSERTED.Id -- etc
    WHERE [Owner] IS NULL
    

    You’d also want a timeout (@expiry) on this, so that when a processor goes down you don’t lose work. You’d also need a task to clear the owner on things that are past their Expiry.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I recently had a problem with two threads sticking in deadlock because they weren't
I recently had a little problem using a jquery plugin with coffeescript (within the
I recently had to build an app which was pretty big (just under 180mb)
We recently had a web app that went out to site acceptance testing where
I recently had a problem in my app where some of the subviews I
I recently had a discussion with another developer who claimed to me that JOINs
I recently had this problem about scrolling and focus changing. I solved it by
I recently had to move my database from SQL Studio over to Oracle and
Having recently had reason to peruse the Nullable documentation, I noticed that the definition
I recently had this idea to create a C# Windows Form App that enables

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.