title: SQL/BigQuery - how to optimize query?
body: <p>I am trying to find an efficient way of finding out what sessions have three or more records that have the same timestamp</p>
  <p><a href="https://i.stack.imgur.com/sTMRK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/sTMRK.png" alt="enter image description here" /></a></p>
  <pre><code>WITH session_base as (
  SELECT
     distinct(sessionID),
     TIMESTAMP_TRUNC(ContentAccess.timestamp, SECOND) as ets,
     COUNT(*) AS event_count
  FROM ContentAccess
      GROUP BY 1,2
      HAVING event_count &gt;= 3
  )
  
  SELECT distinct(sessionid) from session_base
  </code></pre>
  <p>This query takes a very long time to resolve (if ever)., Is there a better way of structuring this query?</p>