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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T19:40:39+00:00 2026-06-09T19:40:39+00:00

I want to have a guide section with a view counter. At the moment

  • 0

I want to have a guide section with a view counter. At the moment I worry about the performance. I would like to have it in real time so if someone views the page i want to increase the counter.

I worry because , what if i would have 1000000 views per day. So I would have to hit my db 1000000 times, to increase the counter. (only on one guide!)

I have problems to calculate the performance hit. Is this a big performance hit or a small performance hit to update an integer?

My workaround would be to cache the views and submit them only every x views. This would reduce the db hits by a factor of x. (for example x=100)

I am using mongohq.com at the moment and it seems that they have a flat pricing model, so I only pay for the storage and not for read/writes.

I am asking because I don’t want to abuse their pricing model.

Edit:

Here is my code of incrementing the views count.

public static void increaseViews(String title) throws UnknownHostException,
            MongoException, DbAuthException {
        Datastore ds = DatabaseConnect.getInstance().getDatastore();
        Query<UserGuides> q = ds.createQuery(UserGuides.class).field("title")
                .equal(title);
        UpdateOperations<UserGuides> ops = ds.createUpdateOperations(
                UserGuides.class).inc("views");
        ds.update(q, ops);
    }
  • 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-09T19:40:41+00:00Added an answer on June 9, 2026 at 7:40 pm

    Disclaimer: I am a founder at MongoHQ

    It is a small performance hit to do this using the $inc operator. MongoDB has a nice way of doing just this.

    For example your query might look like:

    db.pages.update({page: "index"}, {$inc: {hits: 1}})
    

    Mongo can handle these very fast and will work well for what you are doing. If you get to where you are abusing a plan we will politely let you know 😉

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

Sidebar

Related Questions

I want to have Tab panel like this picture I want to implement the
I want to remove the side_body section on each page in RefineryCMS. The guide
I have a GUID variable and I want to write inside a text file
I have an object in Guice with scope singleton. In method f() I want
I have a XMLHTTPRequest that contains SOAP message. I want to add guid that
i want have an image and i want to set it as a background
I have a UITextView and I want have two buttons. When the user taps
I try to read out all existing calendars. I want have a HashMap with
want to have a Hyperlink-Button in a gridView in which I can display a
I have want to save a form in Symfony2, based on a form type,

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.