This gem adds some methods to queue_classic queues that I found helpful:
An index might help to speed up the
job_exists? queries. Although, I haven't really tested if there is much to gain by adding this:
CREATE INDEX idx_qc_unlocked_job_count ON queue_classic_jobs (q_name, method, args) WHERE locked_at IS NULL;
Caveats when comparing args column
The method arguments are serialized to JSON. However, the comparison performed when looking for jobs in the database is a string comparison. Results might be incorrect if there is more than one way to serialize the arguments to a JSON string. It should be safe for simple things like passing a numeric id.
I have some of the original code from there: