title: Correct way to use StringBuilder in SQL
body: <p>I just found some sql query build like this in my project:</p>
  
  <pre><code>return (new StringBuilder("select id1, " + " id2 " + " from " + " table")).toString();
  </code></pre>
  
  <p>Does this <code>StringBuilder</code> achieve its aim, i.e reducing memory usage?</p>
  
  <p>I doubt that, because in the constructor the '+' (String concat operator) is used. Will that take the same amount of memory as using String like the code below? s I understood, it differs when using <code>StringBuilder.append()</code>.</p>
  
  <pre><code>return "select id1, " + " id2 " + " from " + " table";
  </code></pre>
  
  <p>Are both statements equal in memory usage or not? Please clarify. </p>
  
  <p>Thanks in advance!</p>
  
  <p>Edit:</p>
  
  <p>BTW, <strong>it is not my code</strong>. Found it in an old project. Also, the query is not so small as the one in my example. :)</p>