-
-
Save anonymous/c2f9625dc0e26a38b3b1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/lib/Minion/Backend/Pg.pm b/lib/Minion/Backend/Pg.pm | |
index 6e974f5..d15ceaf 100644 | |
--- a/lib/Minion/Backend/Pg.pm | |
+++ b/lib/Minion/Backend/Pg.pm | |
@@ -59,19 +59,22 @@ sub job_info { | |
sub list_jobs { | |
my ($self, $offset, $limit, $options) = @_; | |
- my (@and, @values); | |
- push @and, 'state = ?' and push @values, $options->{state} | |
- if $options->{state}; | |
- push @and, 'task = ?' and push @values, $options->{task} if $options->{task}; | |
- my $where = @and ? 'where ' . join(' and ', @and) : ''; | |
+ warn $self->pg->db->query( | |
+ 'explain analyze select id | |
+ from minion_jobs | |
+ where (state = ? or ?::text is null) and (task = ? or ?::text is null) | |
+ order by id desc | |
+ limit ? | |
+ offset ?', @$options{qw(state state task task)}, $limit, $offset | |
+ )->arrays->flatten->join; | |
return $self->pg->db->query( | |
- "select id | |
+ 'select id | |
from minion_jobs | |
- $where | |
+ where (state = ? or ?::text is null) and (task = ? or ?::text is null) | |
order by id desc | |
limit ? | |
- offset ?", @values, $limit, $offset | |
+ offset ?', @$options{qw(state state task task)}, $limit, $offset | |
)->arrays->map(sub { $self->job_info($_->[0]) })->to_array; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment