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

  • SEARCH
  • Home
  • 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 7415097
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T07:13:55+00:00 2026-05-29T07:13:55+00:00

I have a database table with N records, each of which needs to be

  • 0

I have a database table with N records, each of which needs to be refreshed every 4 hours. The “refresh” operation is pretty resource-intensive. I’d like to write a scheduled task that runs occasionally and refreshes them, while smoothing out the spikes of load.

The simplest task I started with is this (pseudocode):

every 10 minutes:
    find all records that haven't been refreshed in 4 hours
    for each record:
        refresh it
        set its last refresh time to now

(Technical detail: “refresh it” above is asynchronous; it just queues a task for a worker thread pool to pick up and execute.)

What this causes is a huge resource (CPU/IO) usage spike every 4 hours, with the machine idling the rest of the time. Since the machine also does other stuff, this is bad.

I’m trying to figure out a way to get these refreshes to be more or less evenly spaced out — that is, I’d want around N/(10mins/4hours), that is N/24, of those records, to be refreshed on every run. Of course, it doesn’t need to be exact.

Notes:

  • I’m fine with the algorithm taking time to start working (so say, for the first 24 hours there will be spikes but those will smooth out over time), as I only rarely expect to take the scheduler offline.
  • Records are constantly being added and removed by other threads, so so we can’t assume anything about the value of N between iterations.
  • I’m fine with records being refreshed every 4 hours +/- 20 minutes.
  • 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-29T07:13:58+00:00Added an answer on May 29, 2026 at 7:13 am

    Do a full refresh, to get all your timestamps in sync. From that point on, every 10 minutes, refresh the oldest N/24 records.

    The load will be steady from the start, and after 24 runs (4 hours), all your records will be updating at 4-hour intervals (if N is fixed). Insertions will decrease refresh intervals; deletions may cause increases or decreases, depending on the deleted record’s timestamp. But I suspect you’d need to be deleting quite a lot (like, 10% of your table at a time) before you start pushing anything outside your 40-minute window. To be on the safe side, you could do a few more than N/24 each run.

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

Sidebar

Related Questions

I have a database table A which stores records, A has a primary key
I have a table in my database in which records conceptually can be children
Problem: I have a large database table (~500k records) which has a list of
I have a MySQL database table which holds 6 types of records I need
I have a table within my database that has many records, some records share
I have a database table (named Topics) which includes these fields : topicId name
I have a database table called Posts which stores all the information regarding an
Let's say I have an Oracle database table of 40MM 9-digit ZIP codes which
I have loaded an associative array of records from a MySQL database table. The
I have a SQLite database, which needs to be updated. Using the update statement

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.