Skip to content

driver-sql: measure id = ANY(ARRAY(SELECT …)) against the share-grant semi-join for a caller with no grant on PostgreSQL (ADR-0155 step 6 cost) #36034

Open

Description

@objectstack-fleet

repo:objectstack#7 · os-tesla · session_01L9qibyXo4gSy8DJPNz4ANz

Filing gate: ② a measured cost the switch ships with · Source: fleet (#33787 step 6 dev report, open_questions[2]; seat 7's call 2026-11-21T09:20Z: "ship it with the cost stated … and file the ANY(ARRAY()) follow-up card"). Part of #33787.

维护者速读

  • 问题:第 6 步(plugin-sharing: a member with more than 5000 share grants on one object silently loses access to the grants past 5000 (list misses rows, GET answers 404) #33787)上线后,PostgreSQL 上一个"没有任何共享授权"的用户打开列表时,列表总数那条查询不再走负责人索引,改成全表扫描:10 万行从 1.46 ms 变 7.29 ms,100 万行从 7.88 ms 变 42.21 ms。列表本页不受影响,SQLite 不受影响。
  • 这一步做什么:在同样的数据上实测另一种写法 id = ANY(ARRAY(SELECT …)),看它能不能让总数查询回到索引、同时结果行完全不变(D-0)。
  • 不做会怎样:大表上无共享用户的列表总数慢几倍(毫秒级),结果正确。
  • 要你做的:看实测结果后再决定换不换写法(step 3 的 L2 已把这个写法列为你来权衡的选项)。

What is known

  • Step 6 measured, for a caller holding no grant, the list page of 50 and its total (medians of 25 runs). PG16 100k: page 1.59 → 1.72 ms (pkey index scan both), total 1.46 → 7.29 ms; the owner-index Bitmap becomes a Seq Scan with a hashed SubPlan. PG16 1M: page 1.65 → 1.58 ms, total 7.88 → 42.21 ms (Parallel Seq Scan). SQLite 100k and 1M keep the owner index (MULTI-INDEX OR).
  • The statement is ADR-0155 D2's: id IN (SELECT record_id FROM sys_record_share WHERE object_name=? AND recipient_type='user' AND recipient_id=? AND record_id IS NOT NULL AND record_id <> ''), with D2's "⛔ No EXISTS, no correlated form, no join". id = ANY(ARRAY(SELECT …)) is uncorrelated and was named by step 3's L2 as a form for the maintainer to weigh. Whether it is inside D2's text is part of this card's question.

Scope

Dedupe

repo:objectstack-ai/objectstack is:issue "ANY(ARRAY" share → none.

Grade: p3 (a measured milliseconds cost with correct rows; the switch it follows is p2). Type: Task.

Activity

  1. added
    pm:queue
    domain:server
    on Nov 21, 2026
  2. objectstack-fleet commented on Nov 21, 2026

    @objectstack-fleet
    ContributorAuthor

    triage#1 · hotlong · session_01Q4EjjMnyLqJdzuktEmRPXH

    Triage: lands in domain:server (driver-sql, PostgreSQL) · pm:queue; rationale: area:data · Task · after ADR-0155 step 6, the list total for a caller with no share grant leaves the owner index on PostgreSQL (100k rows 1.46 → 7.29 ms, 1M rows 7.88 → 42.21 ms; the page itself and SQLite are unaffected); measure id = ANY(ARRAY(SELECT …)) as an index-friendly form with identical rows (D-0); part of #33787 → p3 as filed (a measured, bounded cost; kept, not closed) · size S.

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:serverpm:queuepriority:p3

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions