title: How Laravel maintains persistent database connection
body: <p>I was developing a Laravel application in LAMP setup at my local machine( my laptop). </p>
  
  <p>For testing purpose, I tried to use the mysql service of <code>Aws RDS</code> instead my local <code>mysql server</code>. Found that, an API call which have only one db call with no join (query: <em>show tables</em>) - takes on average 12s. This is ridiculous. When I am using local mysql server, it is around than 600ms. Until now, PDO::ATTR_PERSISTANT was not enabled.</p>
  
  <p>Logging in <code>Illuminate\Database\Connectors\Connector.php</code> [ inside <code>createConnection()</code> method ], I found that, this method is called for each request. This is for both mysql server. </p>
  
  <p>Then, I set <code>PDO::ATTR_PERSISTANT</code> to <code>true</code>. But response time's are similar.</p>
  
  <p>After looking a more closer, found this in the same file:</p>
  
  <pre><code>/**
   * Create a new PDO connection instance.
   *
   * @param  string  $dsn
   * @param  string  $username
   * @param  string  $password
   * @param  array  $options
   * @return \PDO
   */
  protected function createPdoConnection($dsn, $username, $password, $options)
  {
      if (class_exists(PDOConnection::class) &amp;&amp; ! $this-&gt;isPersistentConnection($options)) {
          return new PDOConnection($dsn, $username, $password, $options);
      }
  
      return new PDO($dsn, $username, $password, $options);
  }
  </code></pre>
  
  <p>And <code>PDOConnection</code> - <em>which <code>extends PDO</code>, that is used when persistent is false</em> - constructor is:</p>
  
  <pre><code>public function __construct($dsn, $user = null, $password = null, array $options = null)
  {
      try {
          parent::__construct($dsn, $user, $password, $options);
          $this-&gt;setAttribute(PDO::ATTR_STATEMENT_CLASS, ['Doctrine\DBAL\Driver\PDOStatement', []]);
          $this-&gt;setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
      } catch (\PDOException $exception) {
          throw new PDOException($exception);
      }
  }
  </code></pre>
  
  <p>It seems, setting <code>PDO::ATTR_PERSISTANT</code> to <code>true</code> has no effect.
  This made me confused. </p>
  
  <ol>
  <li>How actually persistent database connection plays in Laravel?</li>
  <li>What was the reason behind long response time (with mysql service of <code>Aws RDS</code>) ? </li>
  </ol>