2
0
Fork 0
mirror of https://git.asonix.dog/asonix/pict-rs synced 2024-11-20 11:21:14 +00:00

Index on queue_time for job queue, limit to 10 jobs in ID query

This commit is contained in:
asonix 2024-01-04 11:01:25 -06:00
parent 0fd6c459d0
commit 6514487ea9
2 changed files with 12 additions and 0 deletions

View file

@ -1191,6 +1191,7 @@ impl QueueRepo for PostgresRepo {
.and(queue_alias.field(queue).eq(queue_name)),
)
.order(queue_alias.field(queue_time))
.limit(10)
.for_update()
.skip_locked()
.single_value();

View file

@ -0,0 +1,11 @@
use barrel::backend::Pg;
use barrel::{types, Migration};
pub(crate) fn migration() -> String {
let mut m = Migration::new();
m.inject_custom("CREATE INDEX queue_time_index ON job_queue (queue_time);");
m.inject_custom("DROP INDEX queue_status_index;");
m.make::<Pg>().to_string()
}