You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Segment list still signs content file links with one query per segment (N+1) #45252
#45050 batched the segment list's child chunk and attachment queries, but signing file links in segment content still runs once per segment. For each segment whose content contains /files/... links, sign_segment_content looks up which referenced files the current caller may access, then re-signs those links. Called in a loop over the page, this issues one lookup per segment, so a document with many image-bearing segments (common for PDFs and Word files with images) still hits the database once per segment.
Measured on the unit-test SQLite database, with one image link per segment:
Path
1 segment
20 segments
Console list_segments
8 queries
27 queries
Service API load_segment_details
5 queries
24 queries
2. Additional context or comments
Proposal: collect the file IDs referenced by every segment on the page, check access once per tenant, then sign each segment's links against its own tenant's result.
This keeps the existing access checks. The lookup only depends on the tenant and the current file-access scope, not on which segment references the file, so checking the page's IDs together gives the same result as checking them segment by segment. sign_segment_content stays as is for single-segment and retrieval callers.
Activity
github-actions commentedon Nov 17, 2026
Closed due to inactivity. If you have any questions, you can reopen it.