You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
haoliang-net/database/DDL/Collect_Log.md

21 lines
946 B
Markdown

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

# Collect_Log 表设计与索引
- 目标:支持高并发日志写入,便于日后按月分区查询与分析。
- 主键LogId BIGINT AUTO_INCREMENT
- 时间字段LogTime DATETIME作为分区键
- 其他字段示例:
- MachineId VARCHAR(64)
- ProgramName VARCHAR(128)
- Action VARCHAR(32) -- 例如 INSERT/UPDATE/DELETE 或自定义动作
- Result VARCHAR(32) -- 新增/无变化/替换加工程序等结果标签
- RawData JSON -- 原始日志片段
+ - AnalysisSummary JSON -- 分析摘要(由 LogAnalyzer 产出)
- 索引设计:
- INDEX idx_logtime(LogTime)
- INDEX idx_machine_program(MachineId, ProgramName, LogTime)
- FULLTEXT INDEX for JSON fields (若 MariaDB 版本支持,按需启用)
- 分区设计概念:按月 RANGE COLUMNS(LogTime) Partition 名分区如 p2024m01, p2024m02 等。
- 注意:在初始版本中,完整分区脚本需要根据实际 MariaDB 版本做微调。