title: Error message: "PostgreSQL said: could not write block 119518 of temporary file: No space left on device" PostgreSQL
body: <p>I have a query that, intuitively, should work just fine. But, almost immediately after executing, I am served with this error message: </p>
  
  <pre><code>ERROR:  could not write block 119518 of temporary file: No space left on device
  Query failed
  PostgreSQL said: could not write block 119518 of temporary file: No space left on device
  </code></pre>
  
  <p>I have approximately 4.5GB in free storage space.</p>
  
  <p>I've tried whittling down the memory usage by replacing each of the CTEs with materialized views in the hope that would reduce the need for processing power.</p>
  
  <p>Additionally. I've taken these steps -- </p>
  
  <p>--I boosted our AWS instance to the memory-optimized db.r4.16xlarge.</p>
  
  <p>--I ran analyze verbose and vacuum full analyze</p>
  
  <p>--I've stopped all other processes </p>
  
  <p>The query does some small processing in two CTEs and then joins a table (roughly 20M rows) with a smaller lookup table (roughly 500K rows).</p>