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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T22:37:17+00:00 2026-05-11T22:37:17+00:00

Here is the issue. On a site I’ve recently taken over it tracks miles

  • 0

Here is the issue.

On a site I’ve recently taken over it tracks “miles” you ran in a day. So a user can log into the site, add that they ran 5 miles. This is then added to the database.

At the end of the day, around 1am, a service runs which calculates all the miles, all the users ran in the day and outputs a text file to App_Data. That text file is then displayed in flash on the home page.

I think this is kind of ridiculous. I was told they had to do this due to massive performance issues. They won’t tell me exactly how they were doing it before or what the major performance issue was.

So what approach would you guys take? The first thing that popped into my mind was a web service which gets the data via an AJAX call. Perhaps every time a new “mile” entry is added, a trigger is fired and updates the “GlobalMiles” table.

I’d appreciate any info or tips on this.

Thanks so much!

  • 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-11T22:37:17+00:00Added an answer on May 11, 2026 at 10:37 pm

    Answering this question is a bit difficult since there we don’t know all of your requirements and something didn’t work before. So here are some different ideas.

    First, revisit your assumptions. Generating a static report once a day is a perfectly valid solution if all you need is daily reports. Why hit the database multiple times throghout the day if all that’s needed is a snapshot (for instance, lots of blog software used to write html files when a blog was posted rather than serving up the entry from the database each time — many still do as an optimization). Is the “real-time” feature something you are adding?

    I wouldn’t jump to AJAX right away. Use the same input method, just move the report from static to dynamic. Doing too much at once is a good way to get yourself buried. When changing existing code I try to find areas that I can change in isolation wih the least amount of impact to the rest of the application. Then once you have the dynamic report then you can add AJAX (and please use progressive enhancement).

    As for the dynamic report itself you have a few options.

    Of course you can just SELECT SUM(), but it sounds like that would cause the performance problems if each user has a large number of entries.

    If your database supports it, I would look at using an indexed view (sometimes called a materialized view). It should support allows fast updates to the real-time sum data:

    CREATE VIEW vw_Miles WITH SCHEMABINDING AS 
    SELECT SUM([Count]) AS TotalMiles, 
    COUNT_BIG(*) AS [EntryCount],
    UserId
    FROM Miles
    GROUP BY UserID
    GO
    CREATE UNIQUE CLUSTERED INDEX ix_Miles ON vw_Miles(UserId)
    

    If the overhead of that is too much, @jn29098’s solution is a good once. Roll it up using a scheduled task. If there are a lot of entries for each user, you could only add the delta from the last time the task was run.

    UPDATE GlobalMiles SET [TotalMiles] = [TotalMiles] + 
      (SELECT SUM([Count]) 
        FROM Miles 
        WHERE UserId = @id 
          AND EntryDate > @lastTaskRun
        GROUP BY UserId)
    WHERE UserId = @id
    

    If you don’t care about storing the individual entries but only the total you can update the count on the fly:

    UPDATE Miles SET [Count] = [Count] + @newCount WHERE UserId = @id
    

    You could use this method in conjunction with the SPROC that adds the entry and have both worlds.

    Finally, your trigger method would work as well. It’s an alternative to the indexed view where you do the update yourself on a table instad of SQL doing it automatically. It’s also similar to the previous option where you move the global update out of the sproc and into a trigger.

    The last three options make it more difficult to handle the situation when an entry is removed, although if that’s not a feature of your application then you may not need to worry about that.

    Now that you’ve got materialized, real-time data in your database now you can dynamically generate your report. Then you can add fancy with AJAX.

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

Sidebar

Related Questions

Here is my issue. I have an ASPX web site and I have code
So I just changed the PageControl project from Apple's site here . The issue
Having an issue here that I have tried everything I can think of but
If someone can please help I am having an issue with my site in
here is my issue: I have a static html site and under blog I
Here is issue that we have on one of our site: File/directory name bruteforcing
I am having some issue here using LWP::Simple to get ftp site content in
Ok very weird issue here. In the base.html file for the admin site they
My issue here is quite simple : i'm trying to use the jQuery validate
I have a really weird issue here. I'm using my local development server right

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.