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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T19:21:26+00:00 2026-05-17T19:21:26+00:00

So I’m building an app using PHP and MongoDB which will have a fair

  • 0

So I’m building an app using PHP and MongoDB which will have a fair bit of traffic in both reads and writes.. After a couple of months there should be around 2500 reads a second and 200 writes per second (not sure how that really rates in terms of traffic compared to others, though).

I’m a bit curious on what to do when updating a collection; the documentation examples show a shell updating a specific collection field but doesn’t explain what happens when any number of fields from the collection could have been changed.

For example, say I have a user collection (very simplified example):

user = {
  _id     :  MongoId(...),
  name    : 'User One',
  email   : 'email@address.com',
  company : 'Company',
  ...
}

We show all editable fields in a form but the user only changes their email address.

Strictly speaking in terms of performance, would it be best to store original values in hidden inputs to compare them in PHP and then building a query specific to the update?

Or should I replace all of the editable fields anyway?

It will be a collection containing objects and arrays within each other — not the simple one shown here.

I know optimisation comes after, but I’m also looking to pick up good habits with MongoDB too.

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-05-17T19:21:27+00:00Added an answer on May 17, 2026 at 7:21 pm

    You’ll probably be retrieving the entire object so as to display the editable form – I’m assuming here that you’ll be displaying the current name, email, etc. and allowing them to edit and submit the new versions. This means you can check to see what’s changed and update that specifically, rather than uploading and replacing the entire object every time.

    I’d suggest using the optimized update operations: "MongoDB Updating". That way you can perform more optimized in-place operations rather than replacing the entire object every time you want to edit a specific field. You’ll probably be looking mainly at $set, $addToSet, and (if you’re dealing with a lot of nested objects, the $ positional operator.

    From the docs:

    Modifier Operations

    Modifier operations are highly-efficient and useful when updating existing values; for instance, they’re great for incrementing a number. [And other more complicated things]

    …

    a modifier update has the advantages of avoiding the latency involved in querying and returning the object. The modifier update also features operation atomicity and very little network data transfer.

    If you have more specific questions about implementing a particular operation, just ask away.

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

Sidebar

Related Questions

No related questions found

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.