title: performance issue: difference between select s.* vs select *
body: <p>Recently I had some problem in performance of my query. The thing is described here: <a href="https://stackoverflow.com/questions/13306548/poor-hibernate-select-performance-comparing-to-running-directly-how-debug/13398223#13398223">poor Hibernate select performance comparing to running directly - how debug?</a>
  After long time of struggling, I've finally discovered that the query with select prefix like:</p>
  
  <pre><code>    SELECT sth.* FROM Something as sth...
  </code></pre>
  
  <p>Is 300x times slower then query started this way:</p>
  
  <pre><code>    SELECT * FROM Something as sth..
  </code></pre>
  
  <p>Could somebody help me, and answer why is that so? Some external documents on this would be really useful.</p>
  
  <p>The table used for testing was: </p>
  
  <p><strong>SALES_UNIT</strong> table contains some basic info abot sales unit node such as name and etc. The only association is to table SALES_UNIT_TYPE, as ManyToOne. The primary key is ID and field VALID_FROM_DTTM which is date.</p>
  
  <p><strong>SALES_UNIT_RELATION</strong> contains relation PARENT-CHILD between sales unit nodes. Consists of SALES_UNIT_PARENT_ID, SALES_UNIT_CHILD_ID and VALID_TO_DTTM/VALID_FROM_DTTM. No association with any tables. The PK here is ..PARENT_ID, ..CHILD_ID and VALID_FROM_DTTM</p>
  
  <p>The actual queries I've used were:</p>
  
  <pre><code>    SELECT s.* 
      FROM   sales_unit s LEFT JOIN sales_unit_relation r 
                 on (s.sales_unit_id = r.sales_unit_child_id) 
      WHERE  r.sales_unit_child_id IS NULL
  
      SELECT  * 
      FROM    sales_unit s LEFT JOIN sales_unit_relation r 
                 on (s.sales_unit_id = r.sales_unit_child_id) 
      WHERE   r.sales_unit_child_id  IS NULL
  </code></pre>
  
  <p>Same query, both uses left join and only difference is with select.</p>