[xuxueli/xxl-job]xxl_job_log中超过一百万就引起CPU100%

2023-12-22 817 views
1

SELECT COUNT(handle_code) AS triggerdaycount, SUM(CASE WHEN trigger_code IN (0, 200) AND handle_code = 0 THEN 1 ELSE 0 END) AS triggerdaycountrunning , SUM(CASE WHEN handle_code = 200 THEN 1 ELSE 0 END) AS triggerdaycountsuc FROM xxl_job_log WHERE trigger_time BETWEEN ? AND ?

xxl_job_log中超过一百万就引起CPU100% 单独弄个计数而非这样去统计,对于每秒触发的任务 日志将非常多,即使只保留三天也会存在问题 使用CASE WHEN 必将扫描所有

回答

3

JobLogReportHelper中的 Map<String, Object> triggerCountMap = XxlJobAdminConfig.getAdminConfig().getXxlJobLogDao().findLogReport(todayFrom, todayTo);

不建议直接数据库直接基础数据统计,建议采用实时计数方式实现统计

1

目前我临时做法就是XxlJobLogMapper.xml中改成了


<select id="findLogReport" resulttype="java.util.Map">
        SELECT
            COUNT(handle_code) triggerDayCount,
            SUM(CASE WHEN (trigger_code in (0, 200) and handle_code = 0) then 1 else 0 end) as triggerDayCountRunning,
            SUM(CASE WHEN handle_code = 200 then 1 else 0 end) as triggerDayCountSuc
        FROM xxl_job_log
        WHERE **1=0**
    </select>

使用where1=0 返回空数据 不要了

7

你们还能访问官方文档吗,好像挂了

2

可以访问吧