title: Optimizing an SQL query with very large amounts of data
body: <p>First things first: I've looked for similar questions but found nothing that explains why what I'm doing is bad practice so I'm posting a new question even though this is very basic stuff.</p>
  
  <p>I've received complaints that I'm putting too much stress on our db but I can't figure out how to optimize so I'm looking for help here.</p>
  
  <p>I've attached a picture of the structure I'm dealing with at the bottom. What I'm trying to do is the following:
  I need to get a list of people that have performed a specific userAction (lets say 'viewProduct' and then add information about that person regarding their userAge, country and continent.</p>
  
  <p>Ive written the following:</p>
  
  <pre><code>select  u.userId, u.userAge, c.countryName, co.name, ul.createdTime,
          ul.userAction
      from  user_log as ul
      left join  user as u  ON u.userId = ul.userId
      left join  country as c  ON c.id = u.userCountryId
      left join  continent as co  ON co.id = c.continentId
      where  ul.createdTime &gt; '2016-06-01'
        and  u.userAge &gt; 40
        and  (ul.userAction like 'viewProduct'
                or  ul.userAction like 'storeProduct'
                or  ul.userAction like 'addProduct'
             );
  </code></pre>
  
  <p>And this is apparently not good enough so I sincerely hope that someone might be able to help out on how to make this more efficient. I'm not very used to dealing with tables where the entries are in the hundreds of millions.</p>
  
  <p>Thank you in advance!</p>
  
  <p><a href="http://i.stack.imgur.com/1lwsf.png" rel="nofollow">db structure</a></p>