title: How to reduce DTU Usage by my stored procedure
body: <p>I have a system built in .net with an Azure SQL Database. I have a task scheduler table, so in certain situations when something happens in the system it ads a row to this table. Then i have a web job in .net, that checks this table every couple of seconds, and if there is a row there with a status "Pending" it updates this row to "in progress", and then my web job, does the necessary task, and finally it updates the row to "Complete". This all works fine, but the query to check the table is using 100% DTU. The databsae is on SQL Azure S2. There are normally around 500 rows in the table. It sometimes can grow to hundreds of thousands, but they get cleaned out every few weeks. </p>
  
  <p>Can someone help me understand why this is using 100% of the DTU. I know it is run very frequently, but i feel it should not use 100% DTU. </p>
  
  <p>This is my procedure:</p>
  
  <pre><code>ALTER Procedure [tb].[TaskSchedulerItem_Select_NextToProcess]
  (
  @TaskSchedulerId int,
  @DateLastUpdated datetime,
  @CurrentDateTime datetime
  )
  
  AS
  
      SET NOCOUNT ON;
  
  
  Declare @TaskSchedulerItemId int
  
  Select top 1 @TaskSchedulerItemId = TaskSchedulerItemId 
  From TaskSchedulerItem 
  Where 
  (
  ItemStatus in ('PENDING','FAILED')
  or
  (ItemStatus = 'IN PROGRESS' AND DateLastUpdated&lt;DATEADD(MINUTE,-1,@CurrentDateTime))
  )
  and TaskSchedulerId=@TaskSchedulerId
  ORDER BY DateLastUpdated asc
  
  
  UPDATE [TaskSchedulerItem]
     SET 
        ItemStatus = 'IN PROGRESS',
        ItemStatusDescription = 'IN PROGRESS',
        DateLastUpdated = @CurrentDateTime
        output inserted.T`enter code here`askSchedulerId,inserted.TaskSchedulerItemId, inserted.ItemReferenceId,inserted.ItemStatus,inserted.ItemStatusDescription, inserted.DateCreated, inserted.DateLastUpdated, inserted.FailureCount
  Where TaskSchedulerItemId = @TaskSchedulerItemId
  and ItemStatus in ('PENDING','FAILED', 'IN PROGRESS')
  </code></pre>