Skip to content

Commit

Permalink
feat: Add index to async_table to speed up lease deletions (#3235)
Browse files Browse the repository at this point in the history
Lease deletions are done by executing the following sql statement: 
```sql
-- name: ReleaseLease :one
DELETE FROM leases
WHERE idempotency_key = $1 AND key = $2::lease_key
RETURNING true
```

This table is referenced by `leases_id` in the `async_calls` table. So a
deletion needs to lookup of such foreign key within the `async_calls`
table in order to set the row's value to NULL.

This PR adds an index to that foreign_key, so that deletions of leases
can happen much much faster.
  • Loading branch information
andresuribe87 authored Oct 29, 2024
1 parent 95c8b6d commit 6125749
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
-- migrate:up

CREATE INDEX idx_async_calls_lease_id ON async_calls(lease_id);

-- migrate:down

0 comments on commit 6125749

Please sign in to comment.