title: How to tell the query optimizer in SAP Hana to treat union blocks separately?
body: <p>I have an SQL statement of the form</p>
  <pre><code>SELECT some stuff
  union all 
  SELECT some more stuff
  </code></pre>
  <p>The two statements are fairly complicated but if I execute them separately each takes a few seconds, the first has around 100 million rows, the second one only around 12000. If I put the statements together like this, the database works for about 15 minutes and then aborts with the error message 'column search intermediate result exceeds 2 billion rows limitation'.</p>
  <p>I assume this happens because the optimizer tries to work on the statement as a whole and aparently makes some bad choices regarding the order of the operations. As it is doing fine on the individual statements it should be sufficient to tell the optimizer to only look at them individually and not try to optimize the entire statement. Is there an easy way to put some 'boxes' around the statements so they are treated individually?</p>