title: High CPU usage on Cloud SQL causing timeouts
body: <p>We have a postres database that has billions of records in it.</p>
  <p>We have one client that uses our older API to query the database to fetch thousands of records once a day.
  I would say close to the top end of the thousands.</p>
  <p>The API is currently on a compute engine behind a load balancer and during the allotted time I spin up 6 instances of this to attempt to help handle the load.</p>
  <p>What I have found is that the CPU usage on cloud SQL is maxing out at 100% and most of the other stats are fine, it's just the CPU.</p>
  <p>This basically renders our API useless as we can't accept connections and it just shits its self.</p>
  <p>What can we do to help this?</p>
  <p>Here is the CPU utilisation chart
  <a href="https://i.stack.imgur.com/ca3yh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ca3yh.png" alt="enter image description here" /></a></p>
  <p>And the connections
  <a href="https://i.stack.imgur.com/PD84f.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/PD84f.png" alt="enter image description here" /></a></p>
  <p>Read/Writes
  <a href="https://i.stack.imgur.com/mFMzG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mFMzG.png" alt="enter image description here" /></a></p>
  <p>Memory Usage
  <a href="https://i.stack.imgur.com/cFqk6.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cFqk6.png" alt="enter image description here" /></a></p>
  <p>You can see in most of the other charts the readings are well within normal for what we expect.</p>
  <p>I don't really want to have to beef up the CPU usage if it isn't really the actual underlining problem.</p>
  <p>A further thing to note is we have developed a new endpoint for this client specifically to use, they have not got that in place yet, and there is no guarantee that it will reduce the db load.</p>