title: The difference of speed between queries in transaction blocks
body: <p>I have one segment of code that need lock the table to prevent from race conditions.
  like:</p>
  <pre><code>DB::beginTransaction();
  $ps = Product::lockForUpdate()-&gt;select(['sold', 'seller_id', 'id'])-&gt;whereIn('id', $pids)-&gt;get();
  if($ps-&gt;count() &gt; 0) {
  ....
  }
  </code></pre>
  <p>I originally thought that the select builder method will make the model not execute the accessor methods, <em><strong>but it seems that it didn't work.
  I tested the actual delay in Postman, it is far longer than the code</strong></em></p>
  <p><strong>The statement above is wrong, the accessor methods were not executed.</strong>
  So, my problem becomes why the code below can be so much faster:</p>
  <p>below:</p>
  <pre><code>DB::beginTransaction();
  $ps = Product::lockForUpdate()-&gt;select(['sold', 'seller_id', 'id'])-&gt;whereIn('id', $pids)-&gt;where([['sold', '&gt;', 0]])-&gt;count();
  if($ps &gt; 0) {
  ....
  }
  </code></pre>
  <p>The second code is surely faster, but it's almost 10 times faster than the first code. And only in the <strong>DB::transaction</strong> block, the first code will be so slow.
  I wonder how the first one is so slow. How many queries the first code will use to generate a model object. Hence, if I always use the ORM code like that, will it seriously hurt the performance? Or maybe it is slow only in the transaction block, if so then why?</p>
  <p>Sorry if my words are not clear, English is not my native language.</p>