title: how to make SQL having many union faster for high speed
body: <p>I have a query which takes quite a long time for selecting data. Let me share my data schema and do you have any idea for high speed instead of my SQL?</p>
  
  <pre><code>---------------------------------------------------
  time                | statA | statB | statC | ... |
  ---------------------------------------------------
  2018-01-01 00:00:00 |   1   |   2   |   1   | ... | 
  ---------------------------------------------------
  2018-01-01 00:00:01 |   2   |   3   |   5   | ... |
  ---------------------------------------------------
  2018-01-01 00:00:02 |   1   |   4   |   3   | ... |
  ---------------------------------------------------
  ...
  </code></pre>
  
  <p>What I'd like to get using the query looks like:</p>
  
  <pre><code>---------------------------------------
  time                |  stat  |  value  |
  ---------------------------------------
  2018-01-01 00:00:00 | statA  |    1    |
  ---------------------------------------
  2018-01-01 00:00:01 | statA  |    2    |
  ---------------------------------------
  2018-01-01 00:00:02 | statA  |    1    |
  ---------------------------------------
  ...
  ...
  ---------------------------------------
  time                |  stat  |  value  |
  ---------------------------------------
  2018-01-01 00:00:00 | statB  |    2    |
  ---------------------------------------
  2018-01-01 00:00:01 | statB  |    3    |
  ---------------------------------------
  2018-01-01 00:00:02 | statB  |    4    |
  ---------------------------------------
  ...
  ...
  </code></pre>
  
  <p>So,  my query is now </p>
  
  <pre><code>(select time, statA as stat, statA as value
  from table)
  union (
  select time, statB as stat, stastB as value
  from table)
  union (
  select time, statC as stat, stastC as value
  from table)
  </code></pre>
  
  <p>Actually, I'm feeling like I'm so stupid because I have to write same SQLs which are only different with stat id repeatedly.</p>
  
  <p>Any recommendation and ways to develop my SQL?</p>