Title: perf(audit-logs): index organization-level rows and read them as two keyset parts by waleedlatif1 · Pull Request #9437 · simstudioai/sim · GitHub
Open Graph Title: perf(audit-logs): index organization-level rows and read them as two keyset parts by waleedlatif1 · Pull Request #9437 · simstudioai/sim
X Title: perf(audit-logs): index organization-level rows and read them as two keyset parts by waleedlatif1 · Pull Request #9437 · simstudioai/sim
Description: Summary Fixes a regression from #9419 in the organization audit-log listing. #9419 reads a page's ids as one keyset scan per org workspace plus one organization-level branch (workspace_id IS NULL and the org named in metadata or as the resource). No index served that branch in order, so unless the organization had a page of org-level rows near the top, every listing walked every workspace-less audit row in the table, scattered across the heap. Listings got slower and long reads on the replica began hitting recovery-conflict cancellations Migration 0444 adds audit_log_org_level_created_at_id_idx, a partial index on (metadata->>'organizationId', date_trunc('milliseconds', created_at), id) WHERE workspace_id IS NULL AND metadata->>'organizationId' IS NOT NULL. It's built concurrently with the replay-safe invalid-index handling from 0442, and it only holds workspace-less rows that name an organization The org-level branch is split into two disjoint keyset parts: rows naming the org in metadata (read backward through the new index, stopping after a page) and organization-resource rows that don't (read through audit_log_resource_idx, a handful per org). The index alone isn't enough: under the single OR the planner bitmap-ORs both indexes and sorts every org-level row of the organization buildOrgScopeCondition (single-record read, data drain) is unchanged and shares the same two definitions of an org-level row Type of Change Bug fix Other: performance Testing New list-plans.integration.ts: many workspace-less rows from other organizations, then EXPLAINs the SQL queryAuditLogs sends (current members and departed, with and without a cursor). It asserts the metadata part reads the new index and nothing seeks workspace_id IS NULL, and that the index serves it as a backward scan with the cursor in the index condition. Fails on the previous query list-scope.integration.ts adds metadata-only, resource-only and both-matching rows (appear once) and a resource row naming another org, and pages across all parts at several page sizes against the single-predicate reference Autopsy: #9419's tests compared results only, on a fixture of a few dozen rows where walking every workspace-less row costs nothing; nothing asserted the org-level branch's plan Migration replayed with the index missing, valid and invalid; integration suites pass in migrate and push modes bun run lint, type-check, check:audits, check-test-types, check:migrations, drizzle-kit generate (no changes) Checklist Code follows project style guidelines Self-reviewed my changes Tests added/updated and passing 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 Fixes a regression from #9419 in the organization audit-log listing. #9419 reads a page's ids as one keyset scan per org workspace plus one organization-level branch (workspace_id IS N...
X Description: Summary Fixes a regression from #9419 in the organization audit-log listing. #9419 reads a page's ids as one keyset scan per org workspace plus one organization-level branch (workspace_id ...
Opengraph URL: https://github.com/simstudioai/sim/pull/9437
X: @github
Domain: github.com
| react-profiling | 0 |
| react-import-map | react,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-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:e1237dde-6640-601e-7a38-c55ddee5fd89 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | A9C6:20420B:41B6E:60663:6AFB09D5 |
| html-safe-nonce | f5dac349ed98a66537d66b86fe80f65b3592d7732d5e3a66cafe3716cbdfc78b |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBOUM2OjIwNDIwQjo0MUI2RTo2MDY2Mzo2QUZCMDlENSIsInZpc2l0b3JfaWQiOiIzNDUyMTg2NDExMzk3OTY0MzciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 2dbb33cbd36e870a06ed1fb23b7c389070256278ae329d6b0376c0d863052858 |
| hovercard-subject-tag | pull_request:5063621145 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/simstudioai/sim/pull/9437/files |
| twitter:image | https://avatars.githubusercontent.com/u/40672544?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/40672544?s=400&v=4 |
| og:image:alt | Summary Fixes a regression from #9419 in the organization audit-log listing. #9419 reads a page's ids as one keyset scan per org workspace plus one organization-level branch (workspace_id IS N... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 76fb13cb43f1834708971f45a9cfcab5df3177a7582086613d7cdc6e98c4bfde |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/simstudioai/sim git https://github.com/simstudioai/sim.git |
| octolytics-dimension-user_id | 199344406 |
| octolytics-dimension-user_login | simstudioai |
| octolytics-dimension-repository_id | 912559512 |
| octolytics-dimension-repository_nwo | simstudioai/sim |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 912559512 |
| octolytics-dimension-repository_network_root_nwo | simstudioai/sim |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | afc998826cdd963c8f91a96ae5372809ab5e296b |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width