Faster API Responses: Database Index on org_members
Faster API Responses: Database Index on org_members
Version: v0.1.6
Category: Performance
Overview
With the release of v0.1.6, a database index has been added on the org_members.org_id column. This is a foundational performance improvement that benefits every authenticated request made to the platform.
Background
The platform uses tRPC with an orgProcedure middleware layer that validates organisation membership on every authenticated API call. This middleware queries the org_members table by org_id to confirm that the requesting user belongs to the correct organisation before allowing the request to proceed.
The problem
Prior to v0.1.6, the org_members table had no index on org_id. This meant every middleware execution triggered a full table scan — the database engine read every row in the table to find matching records. The cost of this scan grows linearly with the number of rows, meaning performance degrades as organisations, members, and overall platform usage increase.
Because orgProcedure is called on every authenticated tRPC request, this was not an isolated slow query — it was a systemic overhead applied to the entire API surface.
The fix
An index has been added on org_members.org_id. The database engine can now satisfy membership lookups in logarithmic time using the index rather than scanning the full table.
CREated INDEX ON org_members (org_id);
Impact
| Before v0.1.6 | After v0.1.6 | |
|---|---|---|
| Lookup strategy | Full table scan | Index seek |
| Query complexity | O(n) | O(log n) |
| Affected requests | Every authenticated tRPC call | Every authenticated tRPC call |
| API changes | — | None |
| Data migration | — | None |
Who is affected
All users of the platform benefit from this change automatically. No configuration changes, API updates, or client-side changes are required. The improvement is transparent and applies immediately after the index is created during the v0.1.6 database migration.