Skip to content

Commit

Permalink
Remove unnecessary query condition in SqlServerJobQueue.Dequeue
Browse files Browse the repository at this point in the history
  • Loading branch information
odinserj committed Oct 13, 2016
1 parent b014674 commit 98b8338
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/Hangfire.SqlServer/SqlServerJobQueue.cs
Expand Up @@ -57,10 +57,10 @@ public IFetchedJob Dequeue(string[] queues, CancellationToken cancellationToken)
DbTransaction transaction = null;

string fetchJobSqlTemplate =
$@"delete top (1) from [{_storage.SchemaName}].JobQueue with (readpast, updlock, rowlock)
$@"delete top (1) JQ
output DELETED.Id, DELETED.JobId, DELETED.Queue
where (FetchedAt is null or FetchedAt < DATEADD(second, @timeout, GETUTCDATE()))
and Queue in @queues";
from [{_storage.SchemaName}].JobQueue JQ with (readpast, updlock, rowlock, forceseek)
where Queue in @queues";

do
{
Expand All @@ -73,9 +73,7 @@ public IFetchedJob Dequeue(string[] queues, CancellationToken cancellationToken)

fetchedJob = connection.Query<FetchedJob>(
fetchJobSqlTemplate,
#pragma warning disable 618
new { queues = queues, timeout = _options.InvisibilityTimeout.Negate().TotalSeconds },
#pragma warning restore 618
new { queues = queues },
transaction).SingleOrDefault();

if (fetchedJob != null)
Expand Down

0 comments on commit 98b8338

Please sign in to comment.