問(wèn)題描述
我使用的是 MySQL 5.x,有一個(gè)主表包含所有客戶(hù)的統(tǒng)計(jì)數(shù)據(jù).我想對(duì)其運(yùn)行報(bào)告,但不想在同一張表上運(yùn)行它,所以我想每天晚上將數(shù)據(jù)移動(dòng)到僅用于報(bào)告的不同表中.我的問(wèn)題是,為每個(gè)客戶(hù)也有一個(gè)單獨(dú)的表進(jìn)行存檔,還是只為所有客戶(hù)創(chuàng)建一個(gè)存檔表是有益的嗎?系統(tǒng)中可能有數(shù)以千計(jì)的客戶(hù),如果我決定按客戶(hù)將其分解,則可能意味著數(shù)以千計(jì)的存檔表.你的想法?
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?
推薦答案
如果您為每個(gè)客戶(hù)使用個(gè)人,則表的數(shù)量會(huì)增加.
If you use the individual for each customer, tables will grow in number.
如果你有統(tǒng)計(jì)數(shù)據(jù),那么我建議像下面這樣總結(jié)
If you have statistics data then i suggest to summarize it like below
- 將過(guò)去 1 個(gè)月的數(shù)據(jù)保存在同一個(gè)主表中.
- maintable_quartely 表中的季度數(shù)據(jù)/半年數(shù)據(jù),根據(jù)報(bào)告要求保存平均或匯總數(shù)據(jù)
- maintable_archieve 中的舊數(shù)據(jù),其中包含 > 根據(jù)報(bào)告要求平均或匯總的每季度或半年數(shù)據(jù)
如果你想把整個(gè)事情放在一起,你需要組合三個(gè)表.
If you want the whole thing together you need to combine three tables.
另一種方式,使用mysql復(fù)制和master進(jìn)行insert、update、delete和slave進(jìn)行select
other way, use mysql replication and master for insert,update,delete and slave for select
這篇關(guān)于Mysql - 歸檔數(shù)據(jù),使用哪種解決方案?的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!