title: All requests requiring connection to mysql are very very slow (using Phalcon)
body: <p>I've been working on converting an application of mine from CodeIgniter to Phalcon. I've noticed that [query heavy] requests that only took a maximum of 3 or 4 seconds using CI are taking up to 30 seconds to complete using Phalcon!</p>
  
  <p>I've spent days trying to find a solution. I've tried using all the different means of access offered by the framework including submitting raw query strings directly to Phalcon's MySql PDO adapter.</p>
  
  <p>I'm adding my database connection to the service container exactly like it is shown in Phalcon's INVO tutorial:</p>
  
  <pre><code>$di-&gt;set('db', function() use ($config) {
      return new \Phalcon\Db\Adapter\Pdo\Mysql(array(
          "host" =&gt; $config-&gt;database-&gt;host,
          "username" =&gt; $config-&gt;database-&gt;username,
          "password" =&gt; $config-&gt;database-&gt;password,
          "dbname" =&gt; $config-&gt;database-&gt;name
      ));
  });
  </code></pre>
  
  <p>Using webgrind output I've been able to narrow the bottleneck down to the constructor in Phalcon's PDO adapter class (cost is in milliseconds):</p>
  
  <p><img src="https://i.stack.imgur.com/6Gti5.jpg" alt="webgrind output, cost in milliseconds"></p>
  
  <p>I've already profiled and manually tested the relevant SQL to make sure the bottleneck isn't in the database (or my poorly constructed SQL!)</p>