Files
codex-proxy-rs/backend/migrations/0052_storage_write_efficiency.sql
T
ZyyandCodex c94a443620 perf(store): reduce redundant persistence and write amplification
Reuse unchanged catalog TOAST values during refresh. Remove unused analytics source versions and duplicate artifact version storage, retire the covered charge-event index, and index artifact configuration cleanup.

Co-authored-by: Codex <noreply@openai.com>
2026-11-29 18:51:12 +08:00

19 lines
860 B
SQL

-- 投影以源快照重算,精确版本确认由持久队列承担
alter table request_analytics_facts drop column source_version;
-- 制品读取统一使用元数据版本,平台表继续约束同版本同平台的包身份
alter table plugin_artifacts
add constraint plugin_artifacts_metadata_version_ck check (
metadata_json ? 'version'
and jsonb_typeof(metadata_json->'version') = 'string'
and length(metadata_json->>'version') between 1 and 128
),
drop column version;
-- 费用事件按请求去重、按 Key 和完成时间重算,复合索引覆盖现行读取
drop index client_api_key_charge_events_client_api_key_id;
-- 删除制品时按摘要级联清理所有实例的历史配置
create index plugin_version_configurations_artifact_sha256_idx
on plugin_version_configurations (artifact_sha256);