問題描述
我使用的是 MySQL 5.x,有一個主表包含所有客戶的統計數據.我想對其運行報告,但不想在同一張表上運行它,所以我想每天晚上將數據移動到僅用于報告的不同表中.我的問題是,為每個客戶也有一個單獨的表進行存檔,還是只為所有客戶創建一個存檔表是有益的嗎?系統中可能有數以千計的客戶,如果我決定按客戶將其分解,則可能意味著數以千計的存檔表.你的想法?
I am using MySQL 5.x and there is one main table that has the stats combined for all customers. I would like to run reporting on it but dont want to run it on the same table so Im thinking of every night moving the data to a different table that will only be used for reporting. My question is would it be beneficial to have a seperate table for each customer to archive too or just have it just one archive table for all customers? There could be thousands of customers in the system which could mean thousands of archive tables if I decide to break it up by customer. Your thoughts?
推薦答案
如果您為每個客戶使用個人,則表的數量會增加.
If you use the individual for each customer, tables will grow in number.
如果你有統計數據,那么我建議像下面這樣總結
If you have statistics data then i suggest to summarize it like below
- 將過去 1 個月的數據保存在同一個主表中.
- maintable_quartely 表中的季度數據/半年數據,根據報告要求保存平均或匯總數據
- maintable_archieve 中的舊數據,其中包含 > 根據報告要求平均或匯總的每季度或半年數據
如果你想把整個事情放在一起,你需要組合三個表.
If you want the whole thing together you need to combine three tables.
另一種方式,使用mysql復制和master進行insert、update、delete和slave進行select
other way, use mysql replication and master for insert,update,delete and slave for select
這篇關于Mysql - 歸檔數據,使用哪種解決方案?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!