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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T23:08:33+00:00 2026-05-10T23:08:33+00:00

I have a particular PHP page that, for various reasons, needs to save ~200

  • 0

I have a particular PHP page that, for various reasons, needs to save ~200 fields to a database. These are 200 separate insert and/or update statements. Now the obvious thing to do is reduce this number but, like I said, for reasons I won’t bother going into I can’t do this.

I wasn’t expecting this problem. Selects seem reasonably performant in MySQL but inserts/updates aren’t (it takes about 15-20 seconds to do this update, which is naturally unacceptable). I’ve written Java/Oracle systems that can happily do thousands of inserts/updates in the same time (in both cases running local databases; MySQL 5 vs OracleXE).

Now in something like Java or .Net I could quite easily do one of the following:

  1. Write the data to an in-memory write-behind cache (ie it would know how to persist to the database and could do so asynchronously);
  2. Write the data to an in-memory cache and use the PaaS (Persistence as a Service) model ie a listener to the cache would persist the fields; or
  3. Simply start a background process that could persist the data.

The minimal solution is to have a cache that I can simply update, which will separately go and upate the database in its own time (ie it’ll return immediately after update the in-memory cache). This can either be a global cache or a session cache (although a global shared cache does appeal in other ways).

Any other solutions to this kind of problem?

  • 1 1 Answer
  • 1 View
  • 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. 2026-05-10T23:08:34+00:00Added an answer on May 10, 2026 at 11:08 pm

    You should be able to do 200 inserts relatively quickly, but it will depend on lots of factors. If you are using a transactional engine and doing each one in its own transaction, don’t – that creates way too much I/O.

    If you are using a non-transactional engine, it’s a bit trickier. Using a single multi-row insert is likely to be better as the flushing policy of MySQL means that it won’t need to flush its changes after each row.

    You really want to be able to reproduce this on your production-spec development box and analyse exactly why it’s happening. It should not be difficult to stop.

    Of course, another possibility is that your inserts are slow because of extreme sized tables or large numbers of indexes – in which case you should scale your database server appropriately. Inserting lots of rows into a table whose indexes don’t fit into RAM (or doesn’t have RAM correctly configured to be used for caching those indexes) generally gets pretty smelly.

    BUT don’t try to look for a way of complicating your application when there is a way of easily turning it instead, keeping the current algorithm.

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

Sidebar

Related Questions

I have a bunch of input elements that have a particular substring in their
I have noticed that my particular instance of Trac is not running quickly and
In a particular page i have a ascx control which contains a table. Now
If you have a particular line of C code in mind to examine in
Greetings, I have a particular object which can be constructed from a file, as
Using jQuery, how would you find elements which have a particular style (eg: float:
My particular problem: I have a string which specifies an aribitrary type in a
In particular what strengths does it have over caching features of Asp.net
For a particular project I have, no server side code is allowed. How can
I have a plugin installed on my wordpress blog that takes the email address

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.