This commit is contained in:
toom1996
2026-10-18 17:42:10 +08:00
parent 1b06bd5bda
commit 1de1ec46a6
58 changed files with 5281 additions and 19191 deletions

View File

@ -53,3 +53,22 @@ git show c4bafc5:scripts/migrate_single_table/main.go
- 若库里已有同名但口径更窄的旧 `uq_ss_entity (city, year)`,03 会静默跳过、留下错误结构;
这时必须跑 04 纠正(04 的 `DROP` 正是为此)。
- 反过来,若只跑 03 而库里已存在正确的同名索引,跳过是无害的。
---
## 三、2026-10-12 系列(下线 pHash 去重 + 语义向量)
| 顺序 | 文件 | 前提 / 幂等 / 不可逆点 |
| --- | --- | --- |
| 1 | `2026-10-12-01-drop-dedup-add-embeddings.sql` | 下线 pHash 去重(DROP `phash`/`is_duplicate`/`dup_of` + 两个 HNSW 索引 + 死表 `image_duplicates`);`image_embeddings` 的 `kind` 改 `varchar(8)`、`embedding` 改 `vector(768)`,补唯一索引并重建 HNSW。**不可逆**:DROP COLUMN / DROP TABLE 无回滚手段,执行前务必确认 `db/backups/` 有可用备份。`image_embeddings` 零数据,列类型变更无需 `USING`。 |
> 排序提示:本步必须排在「二、2026-09-22」系列**之后**执行——它 DROP 的列由那一系列的代码写入,先删列会让中间态代码报错。
---
## 四、2026-10-13 系列(性能)
| 顺序 | 文件 | 前提 / 幂等 / 不可逆点 |
| --- | --- | --- |
| 1 | `2026-10-13-01-image-list-indexes.sql` | 给 `brand_runway_images (runway_id, is_deleted, sort_order)` 与 `street_snap_images (snap_id, is_deleted, sort_order)` 补索引。原先两张图片表**只有主键 (id)**,「按图集列图片」的查询是 Seq Scan + Sort,图片表上万行时图集页会变慢。`IF NOT EXISTS` 幂等,可重复执行,无不可逆点。 |
| 2 | `2026-10-13-02-image-similar-pairs.sql` | 新建 `image_similar_pairs`(「疑似同款」预计算结果表)。原实现是在**打开图集页时**对每张图实时做向量近邻检索,116 张图的图集要发 116 次查询、每次约 20KB SQL;本机 PostgreSQL 跑在 WSL2 里、Windows 经 wslrelay 访问,该链路大 payload 吞吐约 0.47MB/s,合计要 5 秒。改为入库时(或 `dbtool similarbackfill`)算一次存表后,页面退化为一次小查询。纯新增表,`IF NOT EXISTS` 幂等,无不可逆点。 |