Repository navigation
fix(knowledge,files): per-base kb counts and a modified-order file index - #10026
Merged
Merged
Conversation
…ex the modified-order file list
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
[Medium impact] This PR appears safe to merge. SummaryThis PR counts readable documents one knowledge base at a time and adds an index for files sorted by last modified.
Reviews (1) · Last reviewed commit: "fix(knowledge,files): count knowledge ba..." · Reviewed by Greptile |
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
knowledge_base CROSS JOIN LATERAL), instead of one grouped scan over every listed base. With many bases, the grouped form let the planner over-estimate their documents and AND the base index with bitmaps of every tenant's documents (the sharedwsACL token index and a partial index of unarchived documents) before reading a row. Listing many archived bases with no live documents took seconds warm and close to a minute cold. Measured against real data, the same counts went 4.2s → 0.22s, 1.0s → 0.12s for a mid-size workspace, and stayed level for a single very large basewherewhen unpaged, the page's IDs otherwiseworkspace_files_workspace_active_updated_idx(workspace_id, updated_at, id, same predicate as 0442's upload-order index). Sorting by last modified is the file browser's default, and no index served it, so every list read and sorted all of the workspace's live files. Built concurrently, with 0442's replay-safe recoverydatabase.mockaggregates (count,sum, …) get.as(alias)like drizzle's, which drops a test-local workaround inweekly-refresh.test.tsand shrinks the test-types baseline by oneType of Change
Testing
knowledge-base-list.integration.ts: new case that lists many archived bases and asserts each index read ofdocumentseeks a single base and nothing seq-scansdocument. It fails on the pre-fix grouped count (the scan isknowledge_base_id = ANY(...)) and passes afterfile-listing.integration.ts: new case asserting the whole-workspaceupdatedAt descpage readsworkspace_files_workspace_active_updated_idxwith sorting disabled. It fails without the index and passes with itworkspace-kb-document-access,knowledge-projection,search-index-policy,content-delivery,file-listintegration suites, plusservice.test.tsandweekly-refresh.test.tscheck:migrations,drizzle-kit generate(no drift), migration applied to a fresh database,check:test-types, lint, block-registry checkupdated_atmeans an update that only bumps it can no longer be heap-only. The edits that already touch an indexed column (name, folder, deletion) lose nothingChecklist
test-auditauthoring gate)