title: What's the maximum size of a mysql query, via rails?
body: <p>I don't seem to be able to phrase this question well enough to google the answer.</p>
  
  <p>What's the maximum length of a MySQL 5.1 query? Also, is there a relevant Rails 3 limit?</p>
  
  <p>I have an array of 5,000+ email addresses, and need to grab the associated user ids from the db. My preference would be to do that all in one trip, like:</p>
  
  <pre><code>emails = get_emails # an array of strings
  User.select(:id).where("email in (#{emails * ','})")
  </code></pre>
  
  <p>Even if this works for 5,000, I want to make sure that it will work someday for 50,000. So how big can queries be? And if they can't be that big, what's the next best way to get these ids? Just do the same thing in batches?</p>
  
  <p>For this I care more about the officially supported limits than whatever happens to work on the current versions.</p>