perf(go): simplify realtime plate lookup

This commit is contained in:
lingniu
2026-07-03 07:57:04 +08:00
parent 0aa71402d1
commit 2af2ba3367
3 changed files with 24 additions and 2 deletions

View File

@@ -63,7 +63,7 @@
- 状态schema 使用 `PRIMARY KEY (protocol, vin)`,不保留自增 `id``created_at`,对外只暴露最新 `updated_at`
- 索引:不在 `vehicle_realtime_location` 维护经纬度组合索引;实时表只回答当前态,地理范围和轨迹类查询走 TDengine 历史位置。
- 查询:`/api/realtime/snapshots``/api/realtime/locations` 默认不执行 `COUNT(*)``total` 表示本页返回条数;只有需要精确总数时传 `includeTotal=true`
- 写入:车牌从 `vehicle_identity_binding` 反查时使用 VIN 级短 TTL 内存缓存,避免实时帧每条都打 MySQL缓存不作为事实来源。
- 写入:车牌从 `vehicle_identity_binding` 按 VIN 主键直查,并使用 VIN 级短 TTL 内存缓存,避免实时帧每条都打 MySQL缓存不作为事实来源。
- 生产:项目上线前可直接重建这两张 MySQL 表,实时数据会从 Kafka 新消息继续投影。
7. identity 层只保留两张表。