title: Reusing subqueries in AWS Athena generate large amount of data scanned
body: <p>On AWS Athena, I am trying to reuse computed data using a WITH clause, e.g.</p>
  
  <pre><code>WITH temp_table AS (...)
  SELECT ...
  FROM temp_table t0, temp_table t1, temp_table t2
  WHERE ...
  </code></pre>
  
  <p>If the query is fast, the "Data scanned" goes through the roof. As if <code>temp_table</code> is computed for each time it is reference in the <code>FROM</code> clause.</p>
  
  <p>I don't see the issue if I create a temp table separately and use it multiple times in the query.</p>
  
  <p>Is there a way to really reuse a subquery multiple times without any penalty?</p>