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 8928189
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T08:22:46+00:00 2026-06-15T08:22:46+00:00

Each week a cronjob fires that deletes about 500,000 records from a MySQL table

  • 0

Each week a cronjob fires that deletes about 500,000 records from a MySQL table which uses the InnoDB engine. The table contains web log data for weekly processing and afterwards data which is no longer needed is deleted. There are 3 indexes on this table (no foreign keys), including time which is a unix timestamp.

DELETE FROM global_viewlog WHERE time<1354391592

The problem is that this query when ran last week took over 2 hours to run and during that time my entire server was lagging. ‘iotop’ revealed the hard disks where being written to by MySQL quote vastly and the server load dramatically increased to unhealthy levels.

The table gets written to every click. Is there an elephant in the room that I’m not seeing? I.e., something blindly obvious to optimize this weekly query?

Thanks

  • 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-06-15T08:22:47+00:00Added an answer on June 15, 2026 at 8:22 am

    If you regularly delete old data based on time, partitioning the table based on the same column will make it much faster. It will separate different time periods to different areas on disk so a delete will just be to drop an entire chunk instead of looking at individual rows.

    http://dev.mysql.com/doc/refman/5.5/en/partitioning.html

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

Sidebar

Related Questions

Each restaurant has restaurant branches, each branch must determine which days of the week
Am trying to return the sum of each day of a week in mysql
From wikipedia : During each sprint, typically a two to four week period (with
I am writting an application which needs to periodically (each week for example) loop
We have 10 Linux boxes that must run 100 different tasks each week. These
How can I set a date range value for each week that gets updated
I'm making a chart in C# that is linked to donation data. Each week,
I have a script that goes into Fedex Billing each week when they mail
I'm writing a php script that iterates over the Monday of each week. However
I am creating a table that stores data, actually counter, for products for each

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.