Repository navigation
fix: 减少利润报表按用量逐笔扫描渠道历史 - #955
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
解决的问题与行为变化
RPM 的近全天利润报表在用量汇总期间断开。按事件时间计算渠道归属时,旧查询对每笔用量调用
provider_profit_account_at。在 RPM 的两分钟样本中,PostgreSQL 对手工绑定历史执行了 2,583 次顺序扫描。改为直接按账号、供应商身份及生效时间连接历史表,查询计划可对各历史表建一次哈希表。关联记录与来源
Refs #954。改动基于
production的48dee26a7。部署版本6019c1f43在用量聚合阶段收到取消;随后合入的 #949 增加了报表缓存,本次优化缓存未命中时的查询。没有引入外部补丁。管理员新功能提示
不适用。本次只改现有查询,无新入口、设置、提示 ID 或标签,A/B/C 提示及其关闭行为均不涉及。
复现与验收
EXCEPT ALL,并核对手工绑定生效前、起点和终点的收入。历史区间遵循左闭右开,手工解绑继续屏蔽历史导入绑定,后续 URL 回退规则沿用原逻辑。11 月 19 日 RPM 样本为北京时间 22:35 至 22:37,共 2,583 笔。单次顺序测量中,归属查询由 129.257 ms 降至 3.891 ms,双向差集为 0。近全天窗口旧归属查询的计划估算为 749,944 笔用量。完整报表还有分位数、钱包等聚合,其端到端耗时需另行验证。现有日志无法确定最先发起断开的组件。
实际验证
git diff --checkEXPLAIN (ANALYZE, TIMING OFF, SUMMARY ON)和双向差集backend下利润运维 CI 执行 PostgreSQL integration 测试集TestProviderProfitReportHistoricalOwnerAtManualBoundaries通过(3.10 s),PostgreSQL 日志兼容性与运行影响
API、超时、取消、分页、成本公式及缓存策略沿用现有行为。无需配置或迁移。保留历史供应商身份匹配和手工绑定优先级。变更仅影响利润报表查询;可回滚该提交。样本中的缓存热度及历史表规模会影响实测耗时。
文档与用户可见变化
页面筛选和财务字段沿用原约定,无新增操作或文档入口。
Agent 使用声明
Codex 负责日志与计划分析、实现、回归用例及 PR。运行环境未提供可核实的完整模型 ID 和推理强度档位。
提交前自查
维护增量与待验收(
f070119ce18e9638f1ca24ba024dc2c8dbcc028e)TestProviderProfitReportPreservesHistoricalJoinMultiplicity与TestProviderProfitReportSourceHistoryHalfOpenBoundaries。父任务与独立 reviewer 静态通过,git diff --check通过;未运行本地测试/构建,真实 PostgreSQL 回归和新查询性能仍待本头远程 CI/后续验收。原先两分钟计划测量只对应原提交,不能当作本增量实测。gpt-6.1-sol/ultra,fast 仅 requested。独立 Hermes reviewer 与父任务gpt-6.1-sol,推理强度未知。未生产写入、部署、发版或付费调用。最终提交
f070119ce的归属连接在相同的 RPM 两分钟样本(2,583 笔,4 秒语句上限)复测为 5.223 ms,与原函数按用量 ID、渠道和归属的双向EXCEPT ALL差集为 0。完整报表的线上端到端耗时待部署后验收。