Skip to content

schema sync: implicit indexes on the system columns created_at (with id) and owner_id — default list order and private-OWD reads (epic #33631 R3/R11) #33695

Closed

Description

@objectstack-fleet

domain:server#5 · os-elon-musk · session_016WV4cztR1A2CZoxSZyuoGP

Filing gate: ④ child of epic #33631 (SQL performance; maintainer's direct word on the epic). Items R3 + R11 of the M0 ranked list (#33633): #33631 (comment), corrected by #33631 (comment) (review#2 PASS 6890102899).

Maintainer ruling (seat decision card, 2026-11-15T06:40Z)

「两个都加」: schema sync adds implicit indexes on the two system columns, created_at (as (created_at, id), the default list order) and owner_id (the column a private-OWD read filters on). This supersedes the earlier implicit-index ruling that excluded system columns for want of a measured read.

Measured (corrected, 1M rows)

  • PostgreSQL: the index alone takes the admin default-ordered page 229 → 0.9 ms (member page 101 → 3.2 ms).
  • SQLite: the index does nothing while the vacuous controlled_by_parent chain is in the query; with that chain dropped (the R4 card filed alongside, Blocked-by below) the page goes 1.7 s → 0.09 ms.
  • owner_id: small at 10k rows (1.6 → 1.4 ms); grows with private-object size.

Scope

Business reason

Every default-ordered list of a large object sorts its whole filtered set today; on PG an admin list of 1M rows answers in ~1 ms instead of ~230 ms.

Reader

domain:server#5 area A4 (schema sync), next account; size S.

Dedupe

is:issue is:open implicit index created_at → 5 hits, none on this seam (only #33631 and seat posts); owner_id index system column → 5, none (#33435 is a lint rule).

Activity

  1. added
    enhancement
    priority:p2
    pm:queue
    domain:server
    on Nov 15, 2026
  2. objectstack-fleet commented on Nov 15, 2026

    @objectstack-fleet
    ContributorAuthor

    domain:server#5 · os-elon-musk · session_016WV4cztR1A2CZoxSZyuoGP

    Blocked-by (SQLite half only): #33696. On PostgreSQL this card lands alone.

  3. objectstack-fleet commented on Nov 15, 2026

    @objectstack-fleet
    ContributorAuthor

    domain:server#5 · zhuangjianguo · session_01QsR2jUg7BKfRBcTPyMxbLh

    Claim: PM loop round 1 (area S2 re-sit, #33751 §2; handover 6895263530)
    Session: session_01QsR2jUg7BKfRBcTPyMxbLh
    Account: zhuangjianguo
    Branch: claude/area-A4-33695
    Worktree: /home/claude/wt/area-A4-33695
    Domain: domain:server
    Seat: domain:server#5
    File surface: packages/drivers/driver-sql/src/schema-drift.ts (implicit index set) · packages/drivers/driver-sql/src/sql-driver-schema-sync.ts · packages/drivers/driver-turso/src/** (its schema-sync mirror, if any) · tests beside them · driver conformance ledger rows · .changeset/** · packages/qa/dogfood/bench/sql-perf (run only; a leg edit only if the default-order / owner_id read leg is missing) (stop on breach; explain in the report)
    Container & model: M, mode:subagent, model: TIER_DEFAULT (dispatch-gates --tier: no path-derived mandate), effort: high
    Clause-②: no
    Metadata-protocol: none
    Responsibility: n/a — not a defect card
    Thread-read: 6890503866
    Premise: holds (maintainer ruling 「两个都加」 quoted in the card body; measured numbers from the M0 ranked list as corrected by 6889939163)
    Serial constraints cleared: #32883 (ADR text PR #33382 merged) and #33724 (PR #33769 merged) were the schema-drift.ts predecessors; #33836 (p3) stays serial behind this card; SQLite half lands with or after #33696 (PR #33897 open), PG half lands alone; #33652 (objectql engine files) not touched

  4. added
    pm:dispatched
    and removed
    pm:queue
    on Nov 15, 2026
  5. objectstack-fleet commented on Nov 15, 2026

    @objectstack-fleet
    ContributorAuthor

    domain:server#5 · zhuangjianguo · session_01QsR2jUg7BKfRBcTPyMxbLh

    Pre-claim check (seat rule of 13:55Z, applied after the claim 6895290089)
    Pre-claim lane: domain:server A4 because the seam is packages/drivers/driver-sql/src/schema-drift.ts (implicit index set) and sql-driver-schema-sync.ts; no spec schema bit, no docs/adr/** or skills/** edit, no cloud code
    Pre-claim deps: #32883 / #33724 (schema-drift.ts predecessors) merged via #33382 / #33769; #33696 (Blocked-by, SQLite half only) is NOT merged (PR #33897 open): the PG half is free, and a PR that also adds the SQLite index lands only with or after #33897, as the card says ("SQLite: land with or after the R4 card; PG pays alone")
    Prior rulings read: docs/adr/** grep for implicit index on system columns / created_at / owner_id: no hit; the maintainer ruling in the card body (「两个都加」, seat decision card 2026-11-15T06:40Z) supersedes the earlier card-level implicit-index ruling that excluded system columns; no ADR ⛔ line found; a test pinning the old exclusion, if the dev finds one, is updated under this ruling and named in the report

  6. objectstack-fleet commented on Nov 15, 2026

    @objectstack-fleet
    ContributorAuthor

    domain:server#5 · zhuangjianguo · session_01QsR2jUg7BKfRBcTPyMxbLh
    os-dev-report

    {
      "issue": 33695,
      "status": "done",
      "branch": "claude/area-A4-33695",
      "pr": "https://github.com/objectstack-ai/objectstack/pull/34044",
      "head_sha": "55942169032e5886d7b1ddcc6ed6c304329c8501",
      "session": "session_01QsR2jUg7BKfRBcTPyMxbLh",
      "premise_still_valid": true,
      "summary": "Schema sync now adds two keys to the implicit index set in driver-sql schema-drift.ts. (created_at, id) is built on every table that physically has both builtin columns, and (owner_id) on an object whose fields carry a stored, single-valued owner_id. A declared index whose key starts with the whole system key serves instead. On an existing database the missing index is planned as a safe create_index, built by the next sync (CONCURRENTLY on PG), and a later sync makes no changes. Approved surface extensions: the sql-driver-rotation.ts boot-sync gate now opens on the implicit set, and sql-driver-managed-drift.ts passes physicalColumns, so an adopted table without created_at is never asked for the index. Turso's remote face now composes the full implicit set; it had never built the #31882 reference indexes either. driver-sql exports implicitReferenceIndexes for this. Both dialects ship. The PR body says landing waits for, or rides with, PR #33897 (#33696), per the card's SQLite clause. Hypotheses: H1 held, with two gaps outside schema-drift.ts (the rotation.ts gate and the adopted-table error line) that needed the approved extensions. H2: Turso's local face reuses driver-sql through inheritance, but the remote face has its own composition (remote-transport.ts buildDeclaredIndexDDL), which lacked even the #31882 indexes; it now mirrors the set. H3 held: owner_id only when the field is present, stored and single-valued; created_at on every driver-created table, filtered by physical columns. H4 held: names come from buildIndexName (idx_TABLE_created_at_id, idx_TABLE_owner_id), and a second sync emits zero DDL with empty drift (pinned on SQLite, live PG and the Turso remote face). H5 held on PG at 1M rows: admin default-ordered page statement 317 -> 1.33 ms, HTTP p50 427 -> 119 ms, with the count(*) as the remainder. SQLite gain was nil as predicted (chained plan unchanged); with the chain dropped the page goes 1578 -> 0.16 ms. Bench run at 1M line items on both dialects, before (63e47fee build) vs after, on the same shared box.",
      "tests": "Final head 5594216903 (after merging origin/main), under os-verify-lock with a driver-turso closure build: driver-sql and driver-turso typecheck OK. driver-sql: Test Files 264 passed | 4 skipped (268), Tests 5434 passed | 126 skipped, live postgres RAN (private PG16 on :54995, timezone Asia/Shanghai). driver-turso: Test Files 98 passed (98), Tests 2543 passed | 34 skipped. VERDICT command-exit 0. The first full run (pre-fix pins) had 14 reds, all caused by the new index entering sets that pins enumerate; they were fixed in 4 sql and 4 turso test files. Dependents after a closure build, each exit 0: cli unit (2 files, 21 tests; the other named files are integration tier, CI), metadata-protocol src/migrations (359 tests), metadata overlay-index-single-producer (4), objectql activation-ledger-backfill (17), plugin-auth stored-issuer preflight (10), plugin-security permission-set guard (8), service-automation connector guard (5), service-messaging preference-user-reference (13). Ablations via scripts/ablation-replace.mjs (anchor 1->0, blob moved, restored from HEAD, git status clean after each), all red: A1, rotation gate closed -> 3 red including 'an object with nothing else to index still gets (created_at, id)'; A2, physicalColumns dropped -> 'adopted table with no created_at' red ('expected vi.fn() to not be called at all, but actually been called 1 times'); A3, owner presence check dropped -> 5 red; A4, cover rule reduced to the leading column -> 1 red; A5, Turso remote mirror filtered out -> both parity pins red. These are source-level suites (driver-sql tests import ../src; turso tests import the turso src), so no dist preflight was needed. A throwaway probe found empty drift for an ADR-0057 rotation object on SQLite and PG; it was not committed.",
      "gates": "dispatch-gates --commands --repo objectstack-ai/objectstack derived 71 families. Local, 66 run, each exit 0 (exit captured before any pipe): the 16 first-batch families, the 49 second-batch families, and check-closing-keyword-parity on the PR body. check:query-options-erasure hit a 300 s wrapper timeout (124) once and exited 0 on its rerun. The PR-body gates on the final body: check-changeset-no-major 0, check-closing-keyword-parity 0, check-adr-0087-registration 0, check-partof-closing-keyword 0. eslint --no-inline-config on the touched files: 0. NOT MEASURED (declared narrowing): check:dts-closure, check:published-files, check:sourcemap-no-sources-content, check:dual-build-cjs-loads and check:type-check-debt. Each needs a declaration build under the verify lock; two 540 s acquisitions timed out behind another seat's issue-33699 bundle. CI's Lint & Repo Gates and type-check lanes run them. The --ran reconciliation printed 71 derived, 65 run, 6 UNRUN before the body gate ran. PR check-runs at report time (head 5594216903): all in_progress (Check Changeset, Lint · ESLint, Lint · repo & tooling gates, Lint · PM dispatch-gates, Type Check · workspace, Type Check · debt ledger, Governed Surface Queue Guard, PR-body guards, and the rest). That is the honest value; no conclusion was read yet. pnpm lint is CI's. Merge-tree of HEAD against origin/main: clean (exit 0). No open PR shares a file with this diff; #33854, which touched remote-transport.ts, merged before this branch's merge and auto-merged cleanly.",
      "dogfood_battery": "n/a — no `!` in the PR title and no (narrowing) arm",
      "mcp_calls": "0",
      "api_writes": "3 — git push (branch claude/area-A4-33695, several pushes), fleet-write relay pr_create (objectstack-ai/objectstack#34044, run 43739797164, body read back identical), post-stamped os-dev-report comment on #33695",
      "line_budget": "n/a — no skills/** or ratcheted ledger touched; diff +535/-20 lines before the merge, under the 3000-line threshold",
      "files_changed": [
        "packages/drivers/driver-sql/src/schema-drift.ts",
        "packages/drivers/driver-sql/src/index.ts",
        "packages/drivers/driver-sql/src/sql-driver-rotation.ts (approved extension)",
        "packages/drivers/driver-sql/src/sql-driver-managed-drift.ts (approved extension, one argument)",
        "packages/drivers/driver-turso/src/remote-transport.ts",
        "packages/drivers/driver-sql/src/sql-driver-33695-system-column-indexes.test.ts (new)",
        "packages/drivers/driver-turso/src/turso-33695-implicit-index-parity.test.ts (new)",
        "packages/drivers/driver-sql/src/sql-driver-31882-reference-index-dialects.test.ts",
        "packages/drivers/driver-sql/src/sql-driver-schema.test.ts",
        "packages/drivers/driver-sql/src/sql-driver-20432-unbuildable-declared-index.test.ts",
        "packages/drivers/driver-sql/src/sql-driver-11321-sqlite-audit-default-canonical.test.ts",
        "packages/drivers/driver-turso/src/turso-local-remote-declared-index-parity.test.ts",
        "packages/drivers/driver-turso/src/turso-remote-deferred-ddl.test.ts",
        "packages/drivers/driver-turso/src/turso-remote-drift-apply-limit.test.ts",
        "packages/drivers/driver-turso/src/turso-remote-migration-entries.test.ts",
        ".changeset/33695-system-column-implicit-indexes.md"
      ],
      "deviations": [
        "Approved surface extensions (PM approval relayed mid-run, recorded here as approved, not as breaches): sql-driver-rotation.ts gate; sql-driver-managed-drift.ts one argument. driver-sql src/index.ts gained one export (implicitReferenceIndexes), which the approved Turso mirror needs; that file was not named in the surface.",
        "The #33695 pins were first appended to the 31882 harness file. After the PM's 14:45Z rule they were moved into the card-named files sql-driver-33695-system-column-indexes.test.ts and turso-33695-implicit-index-parity.test.ts. The 31882 file keeps only its owner_id consequence edits.",
        "One rerun of eight fixed test files ran without the lock (--maxWorkers=1), after three 540 s queue timeouts. Declared narrowing.",
        "Five build-reading gate families are NOT MEASURED locally (see gates). Declared narrowing; CI runs them.",
        "Commit trailers use 'Co-Authored-By: Claude' per the dispatch, not the harness reminder's model-named form."
      ],
      "open_questions": [
        {
          "question": "Clause-② stays 'no' as the claim says, but driver-sql gains a public export (implicitReferenceIndexes, with an optional physicalColumns arg). dispatch-gates --tier says a card that widens the public surface owes a review. Does the PM want the seat to treat this export as a Clause-② widening?",
          "options": [
            "A: keep 'Clause-②: no'. The export is a driver-internal composition shared between two first-party drivers, not a metadata or protocol surface.",
            "B: re-declare 'Clause-②: yes (widening)' with a review. The changeset still ships patch, because the kind is none."
          ],
          "recommendation": "A, because no author-writable key, value or wire shape moves; the export only lets driver-turso read the composition driver-sql already owns."
        }
      ],
      "security_findings": "none",
      "out_of_scope_findings": [
        "class: none filed · carrier: none · noted only: on many-tenant databases (organization_id, created_at, id) would serve the default list better than the ruled (created_at, id). This is a design note for the epic (#33631), not a defect; it is recorded in the PR's Acceptance notes.",
        "carrier: none · noted, not filed: the index write cost of the added indexes was not measured (Acceptance notes)."
      ]
    }
  7. objectstack-fleet commented on Nov 15, 2026

    @objectstack-fleet
    ContributorAuthor

    domain:server#5 · zhuangjianguo · session_01QsR2jUg7BKfRBcTPyMxbLh
    Declaration corrected: Clause-②: yes (widening) — new driver-sql export implicitReferenceIndexes (PM ruling)

  8. objectstack-fleet commented on Nov 15, 2026

    @objectstack-fleet
    ContributorAuthor

    domain:server#5 · zhuangjianguo · session_01QsR2jUg7BKfRBcTPyMxbLh

    Landed: PR #34044 merged; Fixes closed this card.

    reading value
    PR #34044 head at landing c42e6266 · ACCEPT 6903023335
    merge 479d1e4817cd4b025a974f8aa2b9e66a6434ca26 at 2026-11-15T23:46Z; card closed (completed) by it

    State change: pm:dispatched and lease:A4 removed, assignee cleared.

  9. removed
    pm:dispatched
    on Nov 15, 2026
  10. added 2 commits that reference this issue on Nov 16, 2026
    479d1e4
    b17c602
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

    area:datadomain:serverenhancementpriority:p2

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions