Question: I am using XAMPP running php 5.3 and mysql version 5.5.27 to develop with on my local machine.

For a long time I have noticed that page load times where hitting the 2-3 second mark but asumed that as I was using a remote MySQL database to connect to it was the latency of that connection adding to the load time.

I have recently begun using the local mysql service running on my machine and the page load time is still constantly above 1 second. 

I have used xDebug profiler along with WinCacheGrind to discover that the line `return new PDO($dsn, $username, $password, $options);` in Laravel4's `Illuminate\Database\Connectors\Connector` file is taking an average of 1,005ms to execute.

My question is this: Given the above, I assume this is PDO causing the issue; why and how do I go about fixing it?

Thank you.

Answer: 
This behavior is documented in the manual:

> 
> When the host name is set to "localhost", then the connection to the server is made thru a domain socket. If PDO\_MYSQL is compiled against libmysqlclient then the location of the socket file is at libmysqlclient's compiled in location. If PDO\_MYSQL is compiled against mysqlnd a default socket can be set thru the pdo\_mysql.default\_socket setting.
> 
> 
> 

<http://php.net/manual/en/ref.pdo-mysql.connection.php#refsect1-ref.pdo-mysql.connection-notes>
I do not know why, but changing the host in my laravel4 mysql configuration from `localhost` to `127.0.0.1` just solved the problem.

The following works :)

```
'mysql' => array(
    'driver'    => 'mysql',
    'host'      => '127.0.0.1',
    'database'  => 'laravel4',
    'username'  => 'laravel4',
    'password'  => 'laravel4',
    'charset'   => 'utf8',
    'collation' => 'utf8_unicode_ci',
    'prefix'    => '',
),

```

I have always assumed that localhost = 127.0.0.1 and so the above change shouldn't have made any difference.