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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T18:42:19+00:00 2026-06-18T18:42:19+00:00

I have a MySQL database table that I need to process. It takes about

  • 0

I have a MySQL database table that I need to process. It takes about 1 second to process 3 rows (due to CURL connections I need to make for each row). So, I need to fork the PHP script in order to have a reasonable time (since I will process up to 10,000 rows for one batch).

I’m going to run 10-30 processes at once, and obviously I need some way to make sure that processes are not overlapping (in terms of which rows they are retrieving and modifying).

From what I’ve read, there are three ways to accomplish this. I’m trying to decide which method is best for this situation.

Option 1: Begin a transaction and use SELECT ... FOR UPDATE and limit the # of rows for each process. Save the data to an array. Update the selected rows with a status flag of “processing”. Commit the transaction and then update the selected rows to a status of “finished”.

Option 2: Update a certain number of rows with a status flag of “processing” and the process ID. Select all rows for that process ID and flag. Work with the data like normal. Update those rows and set the flag to “finished”.

Option 3: Set a LIMIT ... OFFSET ... clause for each process’s SELECT query, so that each process gets unique rows to work with. Then store the row IDs and perform and UPDATE when done.

I’m not sure which option is the safest. I think option 3 seems simple enough, but I wonder is there any way this could fail? Option 2 also seems very simple, but I’m not sure if the locking due to the UPDATE cause everything to slow down. Option 1 seems like the best bet, but I’m not very familiar with FOR UPDATE and transactions, and could use some help.

UPDATE: For clarity, I have currently just one file process.php which selects all the rows and posts the data to a third-party via Curl one-by-one. I’d like to have a fork in this file, so the 10,000 rows can be split among 10-30 child processes.

  • 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-18T18:42:20+00:00Added an answer on June 18, 2026 at 6:42 pm

    I ended up using mult_curl functions (as proposed by Brad) to accomplish this task. I divided the array of rows into groups of 100 using array_chunk() and then configured a multi_curl task to process them. I started out using ParallelCurl, but it did not end up working correctly, so I just coded the mult_curl myself.

    It went from taking almost 2 hours to process 10,000 curl connections to taking just a few minutes.

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

Sidebar

Related Questions

I have a MySQL database, and a particular table in that database will need
I have a MySQL database table that stores the URLs of photos. I need
I have a MySQL database table called Participant that looks something like this: (idParticipant)
I'm trying to normalize a mysql database.... I currently have a table that contains
I'm in the process of cleaning up a MySQL database and have to make
Ok I have a table in my SQL Server database that stores comments. My
I have a junction table in my SQL Server 2005 database that consist of
i have a large mysql database table in which one column contains values ranging
I have mysql database structure like below: CREATE TABLE test ( id int(11) NOT
I have a MySQL database where the table was set up to store the

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.