Skip to content

Commit a95fff4

Browse files
mjcclaude
andcommitted
Add covering index for encoding queue filtering
Create partial index on videos(state, priority DESC, updated_at DESC) for state='crf_searched' to help with filtering and sorting before joining to vmafs. Reduces unnecessary temp sorts on the videos side. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
1 parent 2f71ae3 commit a95fff4

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
defmodule Reencodarr.Repo.Migrations.AddEncodingQueueIndex do
2+
use Ecto.Migration
3+
4+
def up do
5+
# Covering index for encoding queue (videos ready for encoding with state filter)
6+
# Helps with filtering and ordering by priority/updated_at before joining to vmafs
7+
execute("""
8+
CREATE INDEX videos_encoding_queue_index
9+
ON videos (state, priority DESC, updated_at DESC)
10+
WHERE state = 'crf_searched'
11+
""")
12+
end
13+
14+
def down do
15+
execute("DROP INDEX IF EXISTS videos_encoding_queue_index")
16+
end
17+
end

0 commit comments

Comments
 (0)