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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T13:00:52+00:00 2026-06-15T13:00:52+00:00

Working on an app that requires a very large amount of data transferred from

  • 0

Working on an app that requires a very large amount of data transferred from the DB. It includes SELECT and UPDATE queries both (i.e. read and write to the DB).

First I need to get a list of all the products (approx. 1000 SKUs). The SELECT query is very simple:

SELECT
    *
FROM
    `my_db`.`products`

Then some automatic updates are done to each product. The UPDATE query is something like this:

UPDATE
    `my_db`.`products`
SET
    `updated` = NOW(),
    `mods` = `mods` + 1,
    /* a couple more updated fields here, if needed */

Now the question is which one would be faster/better to perform: a single query that manipulates with all the records at once, or a PHP loop (e.g. foreach or while) that works with each product separately (1000 single-row queries)? The latter would require a WHERE model = 'ABC' and LIMIT 1, of course.

To make the matter more complex (and comprehensive), think of other affecting criteria, e.g.:

  • What if a different number of rows was targeted: 100 or 100,000?
  • What if more than one table was involved? See an example of a JOINed query below.

.

SELECT
    *
FROM
    `my_db`.`table1` AS `t1`
    INNER JOIN `my_db`.`table2` AS `t2` ON `t1`.`id` = `t2`.`fk`
    INNER JOIN `my_db`.`table3` AS `t3` ON `t2`.`id` = `t3`.`fk`
    /* Etc. */

Is there a general “rule of thumb” to decide which way is better in this or that situation?

  • 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-15T13:00:54+00:00Added an answer on June 15, 2026 at 1:00 pm

    One good statement which includes 1000 records will always be more efficient than perform 1000 queries, as long as your sql statement is well written.

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

Sidebar

Related Questions

The App that I'm working on requires to parse a very big Json file
I'm working on an iPhone app that requires a basic client/server interaction model. For
I'm currently working on a metro app that requires a few textual resources. Part
I am working on an app which requires that the user be logged in
The iPhone app that I am working on requires GET calls to a 3rd
I'm working on a django app for a site that requires an image gallery.
I'm working on a new web app where a large amount of content (text,
I'm currently working on an app that uses the SSO login from Facebook. I've
I'm currently working on an app for the Android OS that displays some data.
i'm currently working on an app for the android os that requires to fetch

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.