title: How can you write the following Rails Query in SQL?
body: <p>I have the following Rails Query:</p>
  
  <pre><code>Org.find(:all).each do |org|
      Org.update_counters org.id, :users_count =&gt; org.users.length
  end
  </code></pre>
  
  <p>For various reasons, like performance, I need to write this in SQL, so I can execute SQL, and not user Rails to make the update. Any ideas how combing the rails loger into sql is possible?</p>
  
  <p>Thanks</p>