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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T03:05:23+00:00 2026-06-09T03:05:23+00:00

I want to create counters in MySQL database that stores the number of views

  • 0

I want to create counters in MySQL database that stores the number of views per products in a specific day, month and year.

The problems is that I have around 2000 products. I thought about using the following schema:

 id (BIGINT)
 year (INT[4])
 month (TINYINT)
 day (TINYINT)
 product_id (INT)
 pageviews (BIGINT)

The problem with that solution is that if, in the worst case scenario, each product is viewed each day, I will have 2000 rows in my database each day. Multiply is by 36 days and I will have 72,000 each month.

I wanted to know if there is a better way to implement this. I thought that the daily data will be kept only in memory as Application variable (developing in .NET) and as ArrayList. IF I chose that direction, I will have less rows/data, 2000 rows each month.

I really want to keep the cumulative daily page-views. By the way, previews is just for illustration purposes, I will store different data, but that data will be updated very frequently.

If I use the daily column, it will be update very often, almost every 2-5 seconds. I intend to update MySQL async by calling an ASP.NET webservice from Javascript, passing the product_id and increase the counter +1. That’s to prevent the application to wait for the update to occur.

I also want to know the estimate table size. IF I’m doing it right:

BIGINT = 8 bytes

Datetime = 10 bytes

INT – 4 bytes

^if I decide to go with a datatime column instead of year/month/day

30 bytes * 2000 = 60,000 bytes

60KB (approx.) * 30 days = 180KB month

180KB month * 12 months = 2160KB / year

Did I get it right?

  • 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-09T03:05:24+00:00Added an answer on June 9, 2026 at 3:05 am

    Ok I’m not that great in Database design but I know that much…
    you should ask yourself for how long you want to save the daily hits on these 2K products?

    If you want to hold them just for a week then you can calculate how much it’ll take in Size (also if you want to hold them for a month).

    If you want to save it for let’s say a month then you could always make a table each month and save the data from the daily hits to that table and sum them up so you’ll have only 2K rows in each table

    Or you could use a “warehouse” table that will hold all the hits per let’s say month and every month the data will be copied to that warehouse table after you sum it up for each month.

    If you want these hits to be saved indefinitely then that is the way as far as I know (Again not a master in Database design).

    Again this is what you should do if you want to save the hits up to a month.

    Hope I helped you,
    Sagi.

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

Sidebar

Related Questions

i want create a counter that retrieve the number of month, day, hour, minute
I want to create a MySQL trigger that updates a table everytime one of
I want to create a Java counter that counts the amount of wins a
I want create wordpress website into which I want create user management... That means
i want create a custom json data from the mssql 2008 results so that
I want to create a new field (or two) in my table that is
How to create performance counters that are exposed by jmx and accessed via jconsole?
I'm trying to count the number of unique users per day on my java
I just want to create plugin that will when visitor(user,visitor,...) visit some post,remember what
I have a website that has members. I want to create a feature that

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.