Skip to content
This repository has been archived by the owner on Feb 8, 2024. It is now read-only.

Add indexes, drop redundant column #7

Merged
merged 1 commit into from
Dec 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion migrations/20231129172339_job_queue_table.sql
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ CREATE TABLE job_queue(
attempt INT NOT NULL DEFAULT 0,
attempted_at TIMESTAMPTZ DEFAULT NULL,
attempted_by TEXT[] DEFAULT ARRAY[]::TEXT[],
completed_at TIMESTAMPTZ DEFAULT NULL,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
errors jsonb[],
max_attempts INT NOT NULL DEFAULT 1,
Expand All @@ -21,3 +20,9 @@ CREATE TABLE job_queue(
status job_status NOT NULL DEFAULT 'available'::job_status,
target TEXT NOT NULL
);

-- Needed for `dequeue` queries
CREATE INDEX idx_queue_scheduled_at ON job_queue(queue, status, scheduled_at);

-- Needed for UPDATE-ing incomplete jobs with a specific target (i.e. slow destinations)
CREATE INDEX idx_queue_target ON job_queue(queue, status, target);