select created_at from opm_mw_raw_data where 优化 #276

Open
opened 2025-12-26 23:46:34 +08:00 by bigtran · 3 comments
Owner

√ 第一个要做的事情:把opm_mw_raw_data的数据变成两个表,1个月内的,1个月外的,每天定时清理

要写一个定时程序来清理

第二个要做的事情:opm_mw_raw_data 新插入的数据,要增加对应的 列 organ_sign, scode

第三个要做的事情:把硬编码消灭掉

image.png

select '两个月内',count(*) from opm_mw_raw_data where created_at >= DATE_SUB(NOW(), INTERVAL 2 MONTH)
union
select '两个月外',count(*) from opm_mw_raw_data where created_at < DATE_SUB(NOW(), INTERVAL 2 MONTH)
union
select '一个月内',count(*) from opm_mw_raw_data where created_at >= DATE_SUB(NOW(), INTERVAL 1 MONTH)
union
select '一个月外',count(*) from opm_mw_raw_data where created_at < DATE_SUB(NOW(), INTERVAL 1 MONTH)
union
select '15天内',count(*) from opm_mw_raw_data where created_at >= DATE_SUB(NOW(), INTERVAL 15 DAY)
union
select '15天外',count(*) from opm_mw_raw_data where created_at < DATE_SUB(NOW(), INTERVAL 15 DAY)
union
select '7天内',count(*) from opm_mw_raw_data where created_at >= DATE_SUB(NOW(), INTERVAL 7 DAY)
union
select '7天外',count(*) from opm_mw_raw_data where created_at < DATE_SUB(NOW(), INTERVAL 7 DAY)
union
select '3天内',count(*) from opm_mw_raw_data where created_at >= DATE_SUB(NOW(), INTERVAL 3 DAY)
union
select '3天外',count(*) from opm_mw_raw_data where created_at < DATE_SUB(NOW(), INTERVAL 3 DAY);
# √ 第一个要做的事情:把opm_mw_raw_data的数据变成两个表,1个月内的,1个月外的,每天定时清理 ## 要写一个定时程序来清理 # 第二个要做的事情:opm_mw_raw_data 新插入的数据,要增加对应的 列 organ_sign, scode # 第三个要做的事情:把硬编码消灭掉 ![image.png](/attachments/7257d7fa-a7f1-4810-b3e2-b56da1f65fcd) ``` select '两个月内',count(*) from opm_mw_raw_data where created_at >= DATE_SUB(NOW(), INTERVAL 2 MONTH) union select '两个月外',count(*) from opm_mw_raw_data where created_at < DATE_SUB(NOW(), INTERVAL 2 MONTH) union select '一个月内',count(*) from opm_mw_raw_data where created_at >= DATE_SUB(NOW(), INTERVAL 1 MONTH) union select '一个月外',count(*) from opm_mw_raw_data where created_at < DATE_SUB(NOW(), INTERVAL 1 MONTH) union select '15天内',count(*) from opm_mw_raw_data where created_at >= DATE_SUB(NOW(), INTERVAL 15 DAY) union select '15天外',count(*) from opm_mw_raw_data where created_at < DATE_SUB(NOW(), INTERVAL 15 DAY) union select '7天内',count(*) from opm_mw_raw_data where created_at >= DATE_SUB(NOW(), INTERVAL 7 DAY) union select '7天外',count(*) from opm_mw_raw_data where created_at < DATE_SUB(NOW(), INTERVAL 7 DAY) union select '3天内',count(*) from opm_mw_raw_data where created_at >= DATE_SUB(NOW(), INTERVAL 3 DAY) union select '3天外',count(*) from opm_mw_raw_data where created_at < DATE_SUB(NOW(), INTERVAL 3 DAY); ```
Author
Owner

image.png

![image.png](/attachments/0be9a696-f384-4385-af14-3a856ef074dd)
249 KiB
bigtran changed title from select *** from opm_mw_raw_data 优化 to select created_at from opm_mw_raw_data where 优化 2025-12-26 23:55:03 +08:00
Author
Owner

image.png

![image.png](/attachments/415075f2-f861-4643-8379-e43147786e53)
Author
Owner

image.png

![image.png](/attachments/b64694c7-58ab-4155-a8be-364b57a51491)
bigtran added the 6-now-commit-to-fix label 2025-12-27 11:43:14 +08:00
Sign in to join this conversation.