Skip to content

每 build 固定項改維護式記帳——#44 閘的 Q1 逐列探查與 chunkCount() 全表 COUNT 隨索引總量成長(設計決定) #61

Description

@kiki830621

Problem

#58 歸因後,no-op build(也就是每次查詢前的增量併入)剩下兩個隨索引總量成長、與改動量無關的固定項:

  1. 全量 build 跑在單一交易裡:中斷全丟、寫鎖握滿全程、向量全量累積在記憶體 #44 正確性閘 sourcesWithoutCursor()Q1(orphan chunks:chunk_sources 裡沒有對應 chunk 的列)——逐列 b-tree 探查。查詢剩餘 ~1.0–1.3s 的 profile——「1 秒以內」的下一步落點 #58 試過 EXCEPT(3.08 s,更糟)與 count-diff(0.072 s 但不 sound:等價性假設「chunk_sources 無懸空引用」,而那正是本閘要稽核的不變式家族)。
  2. chunkCount()SELECT COUNT(*) 全表走訪。

Q2 已在 #58 改成 EXCEPT(≈2.7×)。#58 之後查詢仍約 1.6 s(當晚語料),「1 秒以內」(#56 的目標)未達。

Type

enhancement(設計決定,非 Simple——動到 #44 閘的語意)

Expected

決定並實作「維護式記帳」:

建議走 Plan/Spectra 路徑(/idd-diagnose 會判)。

Actual

每 build 付兩個 O(索引總量) 的固定成本;#58 的 Simple 範圍刻意沒有偷渡這個設計決定(見其 closing summary)。

Source: surfaced during /idd-close #58 closing summary scan (Step 3.5)


Current Status

  • Phase: diagnosed
  • Updated: 2026-09-07(diagnosis 已 post;更正:chunkCount 0.01 s 非固定成本;方向:trigger 維護 source_count+partial index+按需 --audit;Complexity Spectra;Conflict Class A)

Tasks

  • 1. spec:閘 Q1 改讀結構性計數;完整稽核改 --audit--fullsource_count 衍生欄;layout 6
  • 2. IndexDatabase:欄+trigger+partial index;layoutVersion = 6
  • 3. sourcesWithoutCursor() Q1 讀索引;auditOrphans() 跑舊 Q1
  • 4. IndexBuilder/CLI --audit
  • 5. 測試:trigger ≡ 重算(四條路)+變異;IncrementalEquivalence snapshot 含新欄
  • 6. docs/measurements/ 同時點 A/B(含 chunkCount 更正)
  • 7. CHANGELOG/release notes:升版要 --full

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions