0
I am setting up an e-commerce where I have an area to generate sales reports. These reports are divided by year and month.
Currently I have a query sql
where segment the results by year and month and then get the results I want, for example:
- Sales
- Total sales;
- Total sales in R$;
- Product
- List of products;
- Best selling product;
- Sending
- Total sales sent by post;
- Total sales sent by carrier;
- Paying off
- Total online payments;
- Total payments with deposit;
And so on and so forth...
My doubt is the following, as the reports are fixed, IE, when the month ends has no more to change the data of that month, it would be better I save a table with the reports? Or should I keep them through a new query and filter this information whenever the user accesses the report page?
When making the query every time I need to display the report, I feel it is a very heavy and time consuming query, as there are several related tables, for example, tipoPagamento
, tipoEntrega
, cliente
, etc...
Already registering the report data in a table, the query is simpler, but I will have more information in the database. Note: Within the save scheme in a new table, only the list of products would remain through query, as it would generate unnecessary duplication.
I’m using PHP
and database MySql
.
The filter itself will only be monthly, at least there are no plans to switch to a different reporting method, until these reports are administrative company. But I liked the expansion and considerations you addressed, including with practical example.
– celsomtrindade