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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T21:59:30+00:00 2026-06-13T21:59:30+00:00

I need an advice on optimal approach to store statistical data. There is a

  • 0

I need an advice on optimal approach to store statistical data. There is a project on Django, which has a database (mysql) of 30 000 online games.

Each game has three statistical parameters:

  • number of views,
  • number of plays,
  • number of likes

Now I need to store historical data for these three parameters on a daily basis, so I was thinking on creating a single database which will has five columns:

gameid, number of views, plays, likes, date (day-month-year data). 

So in the end, every day for every game will be logged in one row, so in one day this table will have 30000 rows, in 10 days it will have size of 300000 and in a year it will have size of 10 950 000 rows. I’m not a big specialist in DBA stuff, but this says me, that this quickly will become a performance problem. I’m not talking what will happen in 5 years time.
The data collected in this table is needed for simple graphs

(daily, weekly, monthly, custom range).

Maybe you have better ideas on how to store this data? Maybe noSQL will be more suitable in this case? Really need your advice on this.d

  • 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-13T21:59:31+00:00Added an answer on June 13, 2026 at 9:59 pm

    Partitioning in postgresql works great for big logs. First create the parent table:

    create table  game_history_log (
        gameid integer,
        views integer,
        plays integer,
        likes integer,
        log_date date
    );
    

    Now create the partitions. In this case one for each month, 900 k rows, would be good:

    create table game_history_log_201210 (
        check (log_date between '2012-10-01' and '2012-10-31')
    ) inherits (game_history_log);
    
    create table game_history_log_201211 (
        check (log_date between '2012-11-01' and '2012-11-30')
    ) inherits (game_history_log);
    

    Notice the check constraints in each partition. If you try to insert in the wrong partition:

    insert into game_history_log_201210 (
        gameid, views, plays, likes, log_date
    ) values (1, 2, 3, 4, '2012-09-30');
    ERROR:  new row for relation "game_history_log_201210" violates check constraint "game_history_log_201210_log_date_check"
    DETAIL:  Failing row contains (1, 2, 3, 4, 2012-09-30).
    

    One of the advantages of partitioning is that it will only search in the correct partition reducing drastically and consistently the search size regardless of how many years of data there is. Here the explain for the search for a certain date:

    explain
    select *
    from game_history_log
    where log_date = date '2012-10-02';
                                                  QUERY PLAN                                              
    ------------------------------------------------------------------------------------------------------
     Result  (cost=0.00..30.38 rows=9 width=20)
       ->  Append  (cost=0.00..30.38 rows=9 width=20)
             ->  Seq Scan on game_history_log  (cost=0.00..0.00 rows=1 width=20)
                   Filter: (log_date = '2012-10-02'::date)
             ->  Seq Scan on game_history_log_201210 game_history_log  (cost=0.00..30.38 rows=8 width=20)
                   Filter: (log_date = '2012-10-02'::date)
    

    Notice that apart from the parent table it only scanned the correct partition. Obviously you can have indexes on the partitions to avoid a sequential scan.

    Inheritance Partitioning

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

Sidebar

Related Questions

Recently I'm exploring NoSQL Databases. I need an advice about how to store data
I have a file from which I am reading the data. I need advice
I need advice or directions on how to write an algorithm which will find
I need advice on using stored procedures with Entity Framwork 4.x to return data
I have 3 tables, I need advice on how to get data from them.
I need some advice on how to successfully update mutiple rows in my database
I need some advice. I’m building an app that has a sequence of 4
Need advice here: which of the STL container's operations are considered read-only? Take vector<int>
need advice on data driven test automation. I am doing test automation using C#
Need advice on what is the best approach to get the auto incremented id

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.