title: Creating temporary table runs for 30 minutes and does not finish
body: <p>I am joining 7 tables and trying to create a temporary table for further analysis but my query is not finishing.</p>
  
  <p>Then from the temporary table I am creating another temporary table which would hold distinct values in each column:</p>
  
  <pre><code>create TEMPORARY TABLE all_data_counts as (
  
  select date,
  count(DISTINCT(gclid1)),
  count(DISTINCT(gclid2)),
  count(DISTINCT(gclid3)),
  count(DISTINCT(gclid4)),
  count(DISTINCT(gclid5)),
  count(DISTINCT(gclid6)),
  count(DISTINCT(gclid7)),
  count(DISTINCT(gclid8))
  
  
  from all_data group by date
  );
  
  select * from all_data_counts
  </code></pre>
  
  <p>If I run the full code the query is not finishing after letting it run for 20 minutes.</p>
  
  <p>If I only run the <code>left join</code> part and select it to be displayed it takes 30 seconds to join and display it.</p>
  
  <p>Would you have an idea why would it not create and display the temporary table with <code>count(distinct)</code> values?</p>
  
  <p>The tables have the following rows:</p>
  
  <p>I do understand that this question does not have a MCRE, this is sort of a question with the logic itself, is there some kind of logic which I do not follow when trying to achieve the following output:</p>
  
  <p>all_data_counts</p>
  
  <pre><code>Date         gclid1   gclid2   gclid3   gclid4   gclid5   gclid6   gclid7   gclid8
  2019-12-10   1000     900      800      700      600      500      400      300
  </code></pre>
  
  <p>Thank you for your suggestions.</p>