# CM95 PBF 生产化阶段 v1.4.6 ## 目标 v1.4.6 是 **纯生产查询性能修复**。不改变 NavSea delivery 语义、FID、mapping、Style、Sprite、量化、encoder reconcile、non-renderable omission 或 Japan z12 G=1:7,500 policy。 ## 已确认根因 正确 Japan Dataset 1(1492 cells / 1,282,431 source features)在 z11 高密度生产时,v1.4.5 的 `_fetch_scale_features()` 使用: ```sql FROM chart_feature f JOIN chart_cell c ... JOIN chart_area_geometry g ... WHERE f.dataset_id=? AND f.native_scale=? AND f.geometry_type='AREA' AND four numeric bbox predicates ORDER BY c.source_relative_path, f.source_record_index ``` 代表性 tile EXPLAIN: - `chart_feature` 驱动; - `key=idx_feature_class`; - `rows≈611,396`; - `Using temporary; Using filesort`。 同一 tile 改为 geometry spatial-first 后: - `chart_area_geometry` 驱动; - `type=range`; - `key=spx_area_geom`; - `rows≈38`; - `chart_feature` 通过 PRIMARY KEY `eq_ref` 回表。 ## v1.4.6 修改 ### POINT / LINE / AREA 分别使用现有 MySQL 5.7 SPATIAL INDEX: - `chart_point_geometry.spx_point_geom` - `chart_line_geometry.spx_line_geom` - `chart_area_geometry.spx_area_geom` 查询结构改为: 1. geometry table `FORCE INDEX(spx_*)`; 2. `STRAIGHT_JOIN chart_feature`,防止 MySQL 5.7 重新选择 `chart_feature` 为驱动表; 3. `MBRIntersects(g.geom, tile envelope)` 做 R-tree candidate lookup; 4. 保留 v1.4.5 四个 `f.bbox_*` 条件作为第二道候选一致性 gate; 5. 继续通过 `chart_feature` PRIMARY KEY 读取属性; 6. 不增加/修改 importer schema。 ### Deterministic ordering v1.4.5 的 SQL `ORDER BY c.source_relative_path, f.source_record_index` 会对包含 JSON/WKB 的结果触发大量 disk temporary/filesort。 v1.4.6 删除 SQL ORDER BY,改为 Python 排序,同时保留原有顺序语义: - 外层仍固定 `POINT → LINE → AREA`; - 每一种 geometry 内按 `(source_relative_path, source_record_index)` 排序; - sounding 按 `(source_relative_path, source_record_index, point_index)` 排序。 ### SOUNDING `chart_sounding_point` 同样显式: - `FORCE INDEX(spx_sounding_geom)`; - `STRAIGHT_JOIN chart_feature`; - 保持原 `MBRContains(tile envelope, s.geom)` 语义不变; - 排序移到 Python。 ## 不变项 - Dataset / importer / MySQL schema:不变; - `cm95_to_navsea_v1.yaml`:不变; - FID identity contract:不变; - delivery source-layer contract:不变; - encoder reconcile:不变; - non-renderable label omission:不变; - Japan gap disposition:不变; - Japan z12 G=1:7,500 policy:不变; - z0-z12 extent:不变。 ## Builder contract - project: `0.4.6` - runtime: `0.4.6-production-spatial-candidate-query` - builder: `cm95pbf-builder/0.4.6-spatial-candidate-query` Builder contract 参与 production plan hash,因此必须创建新的 plan / release ID。不得用 v1.4.5 plan 直接继续 v1.4.6 build。 ## 验收 正式 build 前执行: ```powershell & ".\.venv\Scripts\python.exe" .\tools\cm95_v1_4_6_preflight.py & ".\.venv\Scripts\python.exe" .\tools\cm95_v1_4_6_query_equivalence.py ` --dataset-id 1 ``` query equivalence 必须满足: - POINT old IDs == new IDs; - LINE old IDs == new IDs; - AREA old IDs == new IDs; - SOUNDING old IDs == new IDs; - new query geometry table 为第一驱动表; - `type=range`; - 使用对应 `spx_*` index。 最终 release 仍允许 `semantic_completeness=PENDING_REVIEW`,但 technical final status 必须 PASS。