docs(2meet-data-optimizer): ADR-004 search-index mode and 1.1.0 release notes

- ADR-004: HivePress / WooCommerce sites keep native meta as the source of truth and use flat tables as its search index; records the 2.1 write order, shadow_read, Promotion Guard, restore policy and router rules, with known limits
- CONTEXT.md Entity Bridge, BENCHMARK-SCALE.md front-end and write-chain measurements (dev36), CHANGELOG and readme for 1.1.0; version 1.1.0
- composer phpcs uses phpcs.xml like CI (was --standard=WordPress with 2312 false errors)
- Verify: composer phpcs (0); composer test; composer stan
- PR: PR-064
This commit is contained in:
2026-09-26 20:24:42 +08:00
parent aa2da274dd
commit 4fc59b757e
7 changed files with 218 additions and 4 deletions
+32
View File
@@ -63,6 +63,38 @@ SQL 的形狀與實際程式一致:原生是 WP_Query 的 meta_query(每個
6. **dual_write 的寫入成本約為兩倍(0.22 ms 對 0.12 ms)**,絕對值很小,不是瓶頸。
7. **Hot 表和 Entity 表儲存了同一份 listing 資料**(合計約 608 MB),兩者功能重疊。
## 前台與寫入鏈實測(dev36,Release 2.1,2026-09-26)
上面的數字是純 SQL。這一節是真實站台(dev36:HivePress 1.7.31 + Marketplace、WooCommerce 11.1.2、Redis object cache、listing 約 10 萬筆)上的整頁與整條寫入鏈,決策背景見 `adr-004-search-index-mode-for-hp-wc.md`。
**前台搜尋**(`tests/live/tools/fe.sh`:每個 URL 5 次取中位數,`X-S36-Ms` = 整個請求到 `template_redirect`)。「routed」是 post 模式 shadow_read + 核心 2.1 router + HivePress AddOn 0.2.0;「1.0.x」是整合測試當時的 router(報告 `notes/tmdo-integration-test-dev36-2026-09-26.md`)。
| URL | 原生 ms | 1.0.x ms | 2.1 routed ms | ids 與原生相同 |
|---|---:|---:|---:|---|
| listing 價格區間 | 606 | 496 | **311** | 是(found 差 1 為扁平漂移) |
| listing 價格區間 + `_sort=price__asc` | 949 | 1,062 | **428** | 是 |
| listing 時薪區間 + `_sort=hourly_rate__desc` | 843 | — | 873 | 是 |
| listing `_sort=rating__desc` | 1,717 | 1,720 | **870** | 是 |
| listing 關鍵字 + 價格區間 | 748 | — | 743 | 是 |
| vendor 時薪區間 | 102 | — | 86 | 是(found 差 21 為扁平漂移) |
| WC 商店價格篩選 / 價格排序 | 90 / 107 | 88–94 | 102 / 118 | 是(WC 用 lookup 表,不經 router) |
- HivePress 搜尋仍帶 tax_query(排除一個 term),WordPress 因此加上 `GROUP BY posts.ID`,排序需要 temporary + filesort;這是目前 311–428 ms 的主要成本,尚未達到 R-2.1 的 300 ms 目標。
- PR-062b 之前,routed 搜尋因 `posts_request` 改寫而失去 WordPress 的 split query,改撈整列 `posts.*`:同一條 SQL 撈 `*` 要 590 ms,只撈 ID 為 312 ms。
- 量測 gotcha:symlink 切換(`plugins/` → `plugins-dev`)後,PHP-FPM 的 opcache(`revalidate_path=0`)仍執行舊目標的程式,WP-CLI 不受影響;前台數字要先確認實際載入的檔案。
**WP_Query**(`tests/live/tools/qbench.php`,`fields=ids`,20 筆一頁):價格區間 296→76 ms、價格 + verified 360→53 ms、rating ≥ 4.5 248→33 ms、rate + `_thumbnail_id` EXISTS 24→9 ms;OR、多 post type、無 type 數值比較等維持原生,結果與原生相同。
**寫入鏈開銷**(單一程序,disabled 與 dual_write 交替兩輪取平均):
| 寫入 | disabled | dual_write | 增加 |
|---|---:|---:|---:|
| HP listing | 754 ms / 348 q | 976 ms / 434 q | +29% |
| WC product | 215 ms / 129 q | 489 ms / 206 q | +127% |
| vendor(user + post) | 444 ms / 162 q | 630 ms / 230 q | +42% |
WC product 的成本來自 `wc_product` 群組,Release 2.2 移除 WC 扁平化後消失。
## 優化候選(待使用者確認後排入 backlog)
| # | 候選 | 針對 | 預期效果 |