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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T14:50:38+00:00 2026-05-17T14:50:38+00:00

I have a need to give my users time-based statistics about different kinds of

  • 0

I have a need to give my users time-based statistics about different kinds of visitors to their pages, such as how many visitors in the last week / last month / overall, and perhaps where those visitors are coming from. Ideally, the data would be rich enough to allow for expansion/customization/re-aggregation if possible.

My question is how best to organize this in the database. One option would be to create a new record for each visit, containing the visitor’s id and the date.

I suspect that such an approach, while giving me the functionality, would be storage-heavy. Is there a better way to approach this?

  • 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-17T14:50:39+00:00Added an answer on May 17, 2026 at 2:50 pm

    The accepted industry practice is to have a trace-level table and summary-level tables. Trace data means detail log of events. Even though storage is not an issue, the time it takes to count would be an issue. It would be much quicker to query visit counts by the hour than counting the records of the trace table.

    Let us say your trace-level table is

    Trace = [datetime, userId, domain], ipaddr;
    

    As your process inserts into the trace table, it would also create/update records for the summary table.

    Determine a finest granularity of time you wish to accumulate events. It could be minute, hour, day, etc.

    You also need to determine if you wish to count by session or by page request. Would you count a repeated visit on a page as more than one visit? You have to determine all such denominators.

    Define a counter:

    class Counter{
      datetime start;
      int count;
    }
    

    Let us say that you have determined the granularity of by-hour is the most appropriate for the traffic on the site.

    Cumulating by session over the whole site
    At the start of the hour, the counter is reset and the start datetime is set to the current datetime. count is incremented per event that occurs. In your case, it would be a new session event.

    When the next hour arrives, the Counter data is written to a new record in the table

    ByHour = [start], count;
    

    And again, the counter is reset and the start datetime is set to the current datetime.

    What you have now is a table that cumulates incidents of new visits by the hour. So that now you could select the sum of count over all ByHour records over the ranges of all ByHour records that fall within a given day, week, month, year of a specified range.

    In order not to affect the response of the web service, the web service should write those events into a bus or queue, which would be picked up by a separate data loading process.

    Cumulating per page visited
    However, you might want to cumulate by pages

    The cumulator process would need to maintain an instance of the cumulator class per pageId:

    class Counter{
      datetime start;
      int pageId;
      int count;
    }
    

    And, the count record would be:

    ByHour = [start, pageId], count;
    PageID = [pageId], url;
    

    Cumulating per userId, pageId, sessionId, clientIp, anything-goes
    Then, you further determine that you need to cumulate visits per user id. In that case, you might determine that it would be better cumulate by day rather than by the hour. If you cumulated it by hour, you might as well depend on the trace table because counting the scarcity of a user starting a new session or visiting per hour would be as good a glanularity as depending on the trace table.

    The cumulator process would need to maintain an instance of the cumulator class per paramId:

    class Counter{
      datetime start;
      int paramId;
      int count;
    }
    

    And, the count record would be:

    ByDay = [start, paramId], count;
    ParamID = [paramId], paramName;
    

    Where paramName could be “pageId”, “userId”, “clientIp”, etc.

    To prevent losing data, you could update any Counter instances that had changes to the ByDay table every ten minutes, without reseting the counter instances. Reset the start and count only when the day crosses over to a new day.

    class Counter{
      datetime start;
      boolean modified;
      int paramId;
      int count;
    }
    

    The “modified” field is not written to the database table. It is a flag to determine if a Counter instance needs to update the ByDay table. If an update occurs, the “modified” field is reset to “false”.

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

Sidebar

Related Questions

I have a project where I need to give the users several different sets
I have a vb.net web app, and I need to give my users the
I have a problem where I always need to give simple access to my
I have page with lot of users (cca 80k) so I need to save
We have need for a rating system in a project we are working on,
I have need to select a number of 'master' rows from a table, also
I have the need to read the Thunderbird address book on the fly. It
I have a need to display a UITableView containing a user's account credentials. For
I have a need to create a transactional process using an external API that
I have a need to close a parent form from within child form from

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.