ssuhat
ssuhat

Reputation: 7656

Need advice for database design for statistics

Right now I'm building an ecommerce site and there will be statistics using Laravel and MariaDB.

My question is: Right now I have Transactions and Transaction Summary table. Every time transaction is made I will save to those tables.

Do I really need Transaction Summary tables to increase my speed when load statistics page (I don't need to SUM all the transactions amount)?

Thanks.

Upvotes: 1

Views: 67

Answers (1)

Mostafa Vatanpour
Mostafa Vatanpour

Reputation: 1408

My experience shows that it is good idea to summarize a big table to a statistic table. It can be done by scheduling a query runs when the mysql load is low every day or every week and update the statistic table.

Also you can keep only recent records of last month or last year and move the other records to another table to speed up statistic queries.

Upvotes: 1

Related Questions