title: How to improve SQLAlchemy performance?
body: <p>I made a client application that uses HTTP to communicate with a Python 2 server using a simple API. The server uses SQLAlchemy's ORM quite extensively to serve the data for those HTTP requests. The problem is that my CPU usage is quite high even with only few active clients. This server should be able to serve a few hundred clients at the same time at around 1 request a second per client so it should still be manageable (or so I hope).</p>
  
  <p>How can I improve the performance? I know the problem is the ORM as cProfile shows this quite clearly. A single query apparently executes around 10000 Python instructions which seems quite odd. I tried plugging in different database engines/backends and changed the interpreter to Pypy just for fun but it obviously didn't help the original problem and also didn't improve performance.</p>
  
  <p>What am I doing wrong here? I really hope this is a "well, duh!" problem.</p>
  
  <p>Should my relationships be of a different type? eager, lazy, dynamic, etc? Right now, I don't specify anything in particular.</p>
  
  <p>Help greatly appreciated.</p>