title: Azure SQL 100% DTU usage
body: <p>i'm having some problems with the reliability of Azure SQL servers.</p>
  
  <p>sometimes doing complicated queries with subqueries like the following:</p>
  
  <pre><code>SELECT DISTINCT [DeviceName] ,name ,data.[Addr] ,[Signal] FROM (SELECT [DeviceName] ,[Signal] ,MAX([Signal]) OVER (PARTITION BY [Addr]) AS 'MaxSignal',[Timestamp] ,[Addr] ,[PartitionId] ,[EventEnqueuedUtcTime] FROM [dbo].[mytable] WHERE CAST([Timestamp] AS DATETIME) &gt; DATEADD(HOUR,+2,(DATEADD(MINUTE, -10, GETDATE()))) ) data LEFT JOIN mytable ON [dbo].[myreftable].[Addr] = data.[Addr] WHERE [Signal] = [MaxSignal];
  </code></pre>
  
  <p>Is done in almost an instant, like i would assume, at other times simply doing a <code>SELECT COUNT(*) FROM mytable</code>
  Is taking upwards of 30 minutes, and showing a DTU usage graph like this:</p>
  
  <p><img src="https://i.stack.imgur.com/iAMB3.png" alt="DTU usage graph"></p>
  
  <p>Anyone know any solutions to this? is it me doing something completely wrong? or is Azure simply not there yet?</p>