Oban Heavy Query: ``SELECT DISTINCT o0.“queue” FROM “public”.“oban_jobs” AS o0``

Hi all;

We have the below query showing up in our db monitoring
``SELECT DISTINCT o0.“queue” FROM “public”.“oban_jobs” AS o0``

As I understand; pruning is a good way to mitigate this. In the Ready for Production training; the prune window is set to 7 days; which is great for keeping a history – but this table can still get rather large over 7 days.

Looking for guidance if I should be tackling this with a different solution than just pruning?

Thank you! :smiley:

Hi @brent-emb, welcome to the forum!

That query comes from the stager, which is checking for available queues. The DISTINCT portion makes the query expensive, though it should be limited to available jobs. Regardless, it’s a known slow point, and Oban Pro uses an alternative mechanism that is much faster.

It really depends on how many jobs you’re running in an hour, day, week, etc. Some apps only run a handful of jobs a day and others run millions. The prune window in “Ready for Production” is meant to ensure people set something for pruning, but you should absolutely reduce the total time based on your requirements. Keep as few jobs as you need.

Yea we prune after an hour for completed jobs as that can range anywhere from 100k to over a million.