title: How do I make my query using left join to be faster?
body: <p>I have three tables: users (id), projects (id_project, owner_id) and followers (repo_id, user_id). I would like count how many followers one project has. I would like to return all user projects, with and without followers.</p>
  
  <p>Where: 
  id = owner_id = user_id
  id_project = repo_id</p>
  
  <p>I report more than 1,000 users in my query. I did this: </p>
  
  <pre><code> rs = dbSendQuery(mydb, "select p.id_project, p.owner_id, count(f.user_id) from users u left outer join projects p on p.owner_id = u.id and u.id in (123, 526, 852) left outer join followers f on p.id_project = f.repo_id group by p.id;")     
  </code></pre>
  
  <p>The query is too slow. Could anyone give me any suggestions to make the query faster? Am I doing something wrong?</p>
  
  <p>Maybe, I can break into two queries, but how do I get the result of the first (which are the projects of the users) and add in the second query (where I would have the number of followers of the projects) in R?</p>
  
  <p>I am using R and mysql.</p>
  
  <p>Regards,
  Thaciana</p>