Skip to content

Commit

Permalink
always make use call
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed May 23, 2016
1 parent e70ea00 commit ef770ed
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions src/Illuminate/Database/Connectors/MySqlConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ public function connect(array $config)
// connection's behavior, and some might be specified by the developers.
$connection = $this->createConnection($dsn, $config, $options);

if (isset($config['unix_socket'])) {
$connection->exec("use `{$config['database']}`;");
}
$connection->exec("use `{$config['database']}`;");

$collation = $config['collation'];

Expand Down

2 comments on commit ef770ed

@KnutHelland
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an old change, but do you remember why you did this? This adds an unnecessary (?) extra round trip to the db.

I'm working on a project where DBs are located far away, and each such round trip to the database adds an extra 20-100ms to the pageload.

@aykutfarsak
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@taylorotwell why is the use database sql command exist for non-socket dsns? I think it is an unnecessary query because host getHostDsn() returns with database name. I am testing Laravel 5.5 on high load web application, this use database command adds ~1ms to response time.

Please sign in to comment.