title: SaaS application - slow running queries
body: <p>I have a SaaS application running on a LAMP stack. In general, everything runs pretty well.</p>
  
  <p>Most tables have a entity_id field that uniquely identifies each of our customers. We have found that as a table gets more and more records for that entity, that things start slowing down. For example, the 'notes' table returns records extremely quickly if the entity has less than 100 records, but once it gets to a few thousand, then things start getting noticeably slower.</p>
  
  <p>In general, things are architecturally pretty sound and queries have been profiled, etc.</p>
  
  <p>What are the kind of things that we should be looking at doing to improve performance? Is there anything we can be doing at the software architecture layer, or should we just be throwing more hardware at the problem?</p>