René's URL Explorer Experiment


Title: fix(knowledge,files): per-base kb counts and a modified-order file index by waleedlatif1 · Pull Request #10026 · simstudioai/sim · GitHub

Open Graph Title: fix(knowledge,files): per-base kb counts and a modified-order file index by waleedlatif1 · Pull Request #10026 · simstudioai/sim

X Title: fix(knowledge,files): per-base kb counts and a modified-order file index by waleedlatif1 · Pull Request #10026 · simstudioai/sim

Description: Summary The knowledge base list's document count runs as one statement that counts each base on its own (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 shared ws ACL 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 base The list and its live-source supplement now share one base filter: the list's own where when unpaged, the page's IDs otherwise Adds workspace_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 recovery The database.mock aggregates (count, sum, …) get .as(alias) like drizzle's, which drops a test-local workaround in weekly-refresh.test.ts and shrinks the test-types baseline by one Type of Change Bug fix Testing knowledge-base-list.integration.ts: new case that lists many archived bases and asserts each index read of document seeks a single base and nothing seq-scans document. It fails on the pre-fix grouped count (the scan is knowledge_base_id = ANY(...)) and passes after file-listing.integration.ts: new case asserting the whole-workspace updatedAt desc page reads workspace_files_workspace_active_updated_idx with sorting disabled. It fails without the index and passes with it Also ran against real Postgres: workspace-kb-document-access, knowledge-projection, search-index-policy, content-delivery, file-list integration suites, plus service.test.ts and weekly-refresh.test.ts check:migrations, drizzle-kit generate (no drift), migration applied to a fresh database, check:test-types, lint, block-registry check Write cost: indexing updated_at means an update that only bumps it can no longer be heap-only. The edits that already touch an indexed column (name, folder, deletion) lose nothing Checklist Code follows project style guidelines Self-reviewed my changes Tests added/updated and passing (new tests pass the test-audit authoring gate) No new warnings introduced I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

Open Graph Description: Summary The knowledge base list's document count runs as one statement that counts each base on its own (knowledge_base CROSS JOIN LATERAL), instead of one grouped scan over every listed base....

X Description: Summary The knowledge base list's document count runs as one statement that counts each base on its own (knowledge_base CROSS JOIN LATERAL), instead of one grouped scan over every listed b...

Opengraph URL: https://github.com/simstudioai/sim/pull/10026

X: @github

direct link

Domain: github.com

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf
route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:c67754b9-193f-32b6-1e8a-c6366a686b02
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idC14E:2550AC:671100:9139FC:6AFB64CB
html-safe-nonce15f4aa19feb46b0577853850be285b9f7e7bd556e958b7284f84fc580062afef
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDMTRFOjI1NTBBQzo2NzExMDA6OTEzOUZDOjZBRkI2NENCIiwidmlzaXRvcl9pZCI6IjM1MDI1NDQ3MTA2OTYzOTU5NzkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmaccef7e563f9bf37ef33a4873f298cebba3fb81700f5addeeb3c13a044df00e25c
hovercard-subject-tagpull_request:5305614042
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/simstudioai/sim/pull/10026/files
twitter:imagehttps://avatars.githubusercontent.com/u/40672544?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/40672544?s=400&v=4
og:image:altSummary The knowledge base list's document count runs as one statement that counts each base on its own (knowledge_base CROSS JOIN LATERAL), instead of one grouped scan over every listed base....
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
Noneea33d13c96d0ff66bd8fa906b193d2213536b78cb06b0c50a4632c58b1418f94
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/simstudioai/sim git https://github.com/simstudioai/sim.git
octolytics-dimension-user_id199344406
octolytics-dimension-user_loginsimstudioai
octolytics-dimension-repository_id912559512
octolytics-dimension-repository_nwosimstudioai/sim
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id912559512
octolytics-dimension-repository_network_root_nwosimstudioai/sim
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release59ef97164c52cf59bd10558ddec9c4f482763988
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/simstudioai/sim/pull/10026/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fsimstudioai%2Fsim%2Fpull%2F10026%2Ffiles
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fsimstudioai%2Fsim%2Fpull%2F10026%2Ffiles
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=simstudioai%2Fsim
Reloadhttps://github.com/simstudioai/sim/pull/10026/files
Reloadhttps://github.com/simstudioai/sim/pull/10026/files
Reloadhttps://github.com/simstudioai/sim/pull/10026/files
simstudioaihttps://github.com/simstudioai
simhttps://github.com/simstudioai/sim
Codehttps://github.com/simstudioai/sim
Issues129 (129)https://github.com/simstudioai/sim/issues
Pull requests197 (197)https://github.com/simstudioai/sim/pulls
Actionshttps://github.com/simstudioai/sim/actions
Projectshttps://github.com/simstudioai/sim/projects
Security and qualityhttps://github.com/simstudioai/sim/security
Insightshttps://github.com/simstudioai/sim/pulse
Sign up for GitHub https://github.com/signup?return_to=%2Fsimstudioai%2Fsim%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fsimstudioai%2Fsim%2Fissues%2Fnew%2Fchoose
waleedlatif1https://github.com/waleedlatif1
staginghttps://github.com/simstudioai/sim/tree/staging
fix/kb-count-files-updated-indexhttps://github.com/simstudioai/sim/tree/fix/kb-count-files-updated-index
Conversation 2 https://github.com/simstudioai/sim/pull/10026
Commits 1 https://github.com/simstudioai/sim/pull/10026/commits
Checks 83 https://github.com/simstudioai/sim/pull/10026/checks
Files changed https://github.com/simstudioai/sim/pull/10026/files
Please reload this pagehttps://github.com/simstudioai/sim/pull/10026/files
fix(knowledge,files): per-base kb counts and a modified-order file index https://github.com/simstudioai/sim/pull/10026/files#top
Show all changes 1 commit https://github.com/simstudioai/sim/pull/10026/files
91fdcbb fix(knowledge,files): count knowledge base documents per base and ind… waleedlatif1 Nov 14, 2026 https://github.com/simstudioai/sim/pull/10026/commits/91fdcbbba05168bdf321d75676906e0c411fc9cf
Clear filters https://github.com/simstudioai/sim/pull/10026/files
Please reload this pagehttps://github.com/simstudioai/sim/pull/10026/files
Please reload this pagehttps://github.com/simstudioai/sim/pull/10026/files
weekly-refresh.test.ts https://github.com/simstudioai/sim/pull/10026/files#diff-2bc4d06600f76a5c09f7dc316335ae83046d58b532a61c76f4abb0833d4de239
knowledge-base-list.integration.ts https://github.com/simstudioai/sim/pull/10026/files#diff-6da0c32138094e247673dc0f0d61020702c1e8b06cbe194c178e12debabbc723
service.test.ts https://github.com/simstudioai/sim/pull/10026/files#diff-5856177786ea5bfaddee3756ec5ac692c1e3e97c332ec370f6c31f401649abb8
service.ts https://github.com/simstudioai/sim/pull/10026/files#diff-6978b26968fd05cf5c7635c366c8c806693b6145235f476627302fb402f32d18
file-listing.integration.ts https://github.com/simstudioai/sim/pull/10026/files#diff-f32775fb7adda2b1d93ebbfa218f14bf471b00fa9e01afe430dd6966d31ee667
0458_workspace_files_active_updated_idx.sql https://github.com/simstudioai/sim/pull/10026/files#diff-c5927a290e421fe35d3016ebef72762c9aecb387429fcb6e8bd6e40266a40a39
0458_snapshot.json https://github.com/simstudioai/sim/pull/10026/files#diff-8bc19b4a2f886efcfcfb24e097043fb55c997285ae25a3e75de0bf88ac7f4317
_journal.json https://github.com/simstudioai/sim/pull/10026/files#diff-37150cc65ad16ee6fbc5fa318fc096be7730e16d63eaf863e3df5521b7030649
schema.ts https://github.com/simstudioai/sim/pull/10026/files#diff-9a959e2ce3cb4c86957bbae021d06eae364f7b0cb18964f5873bab53220af928
explain.ts https://github.com/simstudioai/sim/pull/10026/files#diff-3451bc7f5ca17320150a86318e313f926a5011e2b31d1fa9c7904d1515b7b142
database.mock.ts https://github.com/simstudioai/sim/pull/10026/files#diff-859f381ad1b6a93489bef08c44a1044a2c3cc6f9b98b8d973bb5b0ef893ba42b
check-test-types.baseline.json https://github.com/simstudioai/sim/pull/10026/files#diff-3f0e52298332b82e821be5c9210ddb89bb43ab248c2db79c27e6a783dbfe9e36
apps/sim/lib/billing/credits/weekly-refresh.test.tshttps://github.com/simstudioai/sim/pull/10026/files#diff-2bc4d06600f76a5c09f7dc316335ae83046d58b532a61c76f4abb0833d4de239
View file https://github.com/simstudioai/sim/blob/91fdcbbba05168bdf321d75676906e0c411fc9cf/apps/sim/lib/billing/credits/weekly-refresh.test.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/simstudioai/sim/pull/10026/{{ revealButtonHref }}
https://github.com/simstudioai/sim/pull/10026/files#diff-2bc4d06600f76a5c09f7dc316335ae83046d58b532a61c76f4abb0833d4de239
https://github.com/simstudioai/sim/pull/10026/files#diff-2bc4d06600f76a5c09f7dc316335ae83046d58b532a61c76f4abb0833d4de239
apps/sim/lib/knowledge/__integration__/knowledge-base-list.integration.tshttps://github.com/simstudioai/sim/pull/10026/files#diff-6da0c32138094e247673dc0f0d61020702c1e8b06cbe194c178e12debabbc723
View file https://github.com/simstudioai/sim/blob/91fdcbbba05168bdf321d75676906e0c411fc9cf/apps/sim/lib/knowledge/__integration__/knowledge-base-list.integration.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/simstudioai/sim/pull/10026/{{ revealButtonHref }}
https://github.com/simstudioai/sim/pull/10026/files#diff-6da0c32138094e247673dc0f0d61020702c1e8b06cbe194c178e12debabbc723
https://github.com/simstudioai/sim/pull/10026/files#diff-6da0c32138094e247673dc0f0d61020702c1e8b06cbe194c178e12debabbc723
https://github.com/simstudioai/sim/pull/10026/files#diff-6da0c32138094e247673dc0f0d61020702c1e8b06cbe194c178e12debabbc723
https://github.com/simstudioai/sim/pull/10026/files#diff-6da0c32138094e247673dc0f0d61020702c1e8b06cbe194c178e12debabbc723
https://github.com/simstudioai/sim/pull/10026/files#diff-6da0c32138094e247673dc0f0d61020702c1e8b06cbe194c178e12debabbc723
https://github.com/simstudioai/sim/pull/10026/files#diff-6da0c32138094e247673dc0f0d61020702c1e8b06cbe194c178e12debabbc723
https://github.com/simstudioai/sim/pull/10026/files#diff-6da0c32138094e247673dc0f0d61020702c1e8b06cbe194c178e12debabbc723
apps/sim/lib/knowledge/service.test.tshttps://github.com/simstudioai/sim/pull/10026/files#diff-5856177786ea5bfaddee3756ec5ac692c1e3e97c332ec370f6c31f401649abb8
View file https://github.com/simstudioai/sim/blob/91fdcbbba05168bdf321d75676906e0c411fc9cf/apps/sim/lib/knowledge/service.test.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/simstudioai/sim/pull/10026/{{ revealButtonHref }}
https://github.com/simstudioai/sim/pull/10026/files#diff-5856177786ea5bfaddee3756ec5ac692c1e3e97c332ec370f6c31f401649abb8
https://github.com/simstudioai/sim/pull/10026/files#diff-5856177786ea5bfaddee3756ec5ac692c1e3e97c332ec370f6c31f401649abb8
https://github.com/simstudioai/sim/pull/10026/files#diff-5856177786ea5bfaddee3756ec5ac692c1e3e97c332ec370f6c31f401649abb8
apps/sim/lib/knowledge/service.tshttps://github.com/simstudioai/sim/pull/10026/files#diff-6978b26968fd05cf5c7635c366c8c806693b6145235f476627302fb402f32d18
View file https://github.com/simstudioai/sim/blob/91fdcbbba05168bdf321d75676906e0c411fc9cf/apps/sim/lib/knowledge/service.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/simstudioai/sim/pull/10026/{{ revealButtonHref }}
https://github.com/simstudioai/sim/pull/10026/files#diff-6978b26968fd05cf5c7635c366c8c806693b6145235f476627302fb402f32d18
https://github.com/simstudioai/sim/pull/10026/files#diff-6978b26968fd05cf5c7635c366c8c806693b6145235f476627302fb402f32d18
https://github.com/simstudioai/sim/pull/10026/files#diff-6978b26968fd05cf5c7635c366c8c806693b6145235f476627302fb402f32d18
https://github.com/simstudioai/sim/pull/10026/files#diff-6978b26968fd05cf5c7635c366c8c806693b6145235f476627302fb402f32d18
https://github.com/simstudioai/sim/pull/10026/files#diff-6978b26968fd05cf5c7635c366c8c806693b6145235f476627302fb402f32d18
https://github.com/simstudioai/sim/pull/10026/files#diff-6978b26968fd05cf5c7635c366c8c806693b6145235f476627302fb402f32d18
apps/sim/lib/workspace-files/__integration__/file-listing.integration.tshttps://github.com/simstudioai/sim/pull/10026/files#diff-f32775fb7adda2b1d93ebbfa218f14bf471b00fa9e01afe430dd6966d31ee667
View file https://github.com/simstudioai/sim/blob/91fdcbbba05168bdf321d75676906e0c411fc9cf/apps/sim/lib/workspace-files/__integration__/file-listing.integration.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/simstudioai/sim/pull/10026/{{ revealButtonHref }}
https://github.com/simstudioai/sim/pull/10026/files#diff-f32775fb7adda2b1d93ebbfa218f14bf471b00fa9e01afe430dd6966d31ee667
https://github.com/simstudioai/sim/pull/10026/files#diff-f32775fb7adda2b1d93ebbfa218f14bf471b00fa9e01afe430dd6966d31ee667
packages/db/migrations/0458_workspace_files_active_updated_idx.sqlhttps://github.com/simstudioai/sim/pull/10026/files#diff-c5927a290e421fe35d3016ebef72762c9aecb387429fcb6e8bd6e40266a40a39
View file https://github.com/simstudioai/sim/blob/91fdcbbba05168bdf321d75676906e0c411fc9cf/packages/db/migrations/0458_workspace_files_active_updated_idx.sql
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/simstudioai/sim/pull/10026/{{ revealButtonHref }}
Please reload this pagehttps://github.com/simstudioai/sim/pull/10026/files
Please reload this pagehttps://github.com/simstudioai/sim/pull/10026/files
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.