title: Is there a way to increase allotted memory for queries in BigQuery?
body: <p>I have a large table (about 59 millions rows, 7.1 GB) already ordered as i want, and I want to query this table and get a row_number() for each row of the table.
  Unfortunately I get the error</p>
  <blockquote>
  <p>Resources exceeded during query execution: The query could not be executed in the allotted memory.</p>
  </blockquote>
  <p>Is there a way to increase allotted memory in BigQuery ?</p>
  <p>Here is my query, I don't see how I can simplify it, but if you have any advices I'll take it</p>
  <pre><code>SELECT
    row_number() over() as rowNumber,
    game,
    app_version,
    event_date,
    user_pseudo_id,
    event_name,
    event_timestamp,
    country,
    platform
  FROM
  `mediation_time_BASE`
  </code></pre>
  <p>Here is the complete error message :</p>
  <blockquote>
  <p>Resources exceeded during query execution: The query could not be executed in the allotted memory. Peak usage: 146% of limit. Top memory consumer(s): analytic OVER() clauses: 98% other/unattributed: 2%</p>
  </blockquote>
  <p><strong>Edit:</strong>
  the query here represents a list of event starts and ends, and I need to link the start event with its end, so I follow this tip : <a href="https://www.interfacett.com/blogs/how-to-use-values-from-previous-or-next-rows-in-a-query-in-sql-server/" rel="nofollow noreferrer">https://www.interfacett.com/blogs/how-to-use-values-from-previous-or-next-rows-in-a-query-in-sql-server/</a>
  For that I need to have the rows with row_number() in order to separate this subquery in 2 (event start in one hand and event end in the other), join them and then have one row per event with the start and end of the event, as follow (where subquery represents the query with the row_number()):</p>
  <pre><code>SELECT
     (case when lead(inter.rowNumber) OVER(ORDER BY inter.rowNumber) - inter.rownumber =1
            then lead(inter.rowNumber) OVER(ORDER BY inter.rowNumber)
            else inter.rownumber end) as rowNumber,
      min(inter_success.rowNumber) as rowNumber_success,
      inter.game,
      inter.app_version,
      inter.event_date,
      inter.user_pseudo_id,
      inter.event_timestamp as event_start,
      min(inter_success.event_timestamp) as event_end,
      inter_success.event_name as results
  FROM
      (SELECT * FROM `subquery` where event_name = 'interstitial_fetch') as inter INNER JOIN 
      (SELECT * FROM `subquery` where event_name = 'interstitial_fetch_success') as inter_success
              ON inter.rowNumber &lt; inter_success.rowNumber and inter.game= inter_success.game and inter.app_version = inter_success.app_version and inter.user_pseudo_id = inter_success.user_pseudo_id 
  GROUP BY inter.rowNumber,inter.game,inter.app_version,inter.event_date,inter.user_pseudo_id,inter.event_timestamp,inter_success.event_name
  </code></pre>
  <p>This works fine with a smaller dataset, but doesn't for 59 million rows...</p>