Performance only.
Install joomla on localhost. Set configuration.php public $host = 'localhost';
(This is a wamp server, default by xampp).
Turn on debug mode for server.
Open any page or administration page.
Fast connection to db as this is localhost.
Note: solution provided below
Connection time is > 1 second.
Time: 1.0 ms / 1.0 ms Memory: 0.652 MB / 0.65 MB Application: afterLoad
*** Time: 1187.1 ms / 1188.1 ms Memory: 3.930 MB / 4.58 MB Application: afterInitialise
Time: 23.0 ms / 1211.1 ms Memory: 0.345 MB / 4.93 MB Application: afterRoute
with provided fix:
Time: 159.0 ms / 160.0 ms Memory: 3.936 MB / 4.59 MB Application: afterInitialise
This can be changed easily in
/libraries/joomla/database/driver/mysqli.php
by using gethostbyname(..);
at around line 160
change:
$this->connection = @mysqli_connect(
$this->options['host'], $this->options['user'], $this->options['password'], null, $this->options['port'], $this->options['socket']
);
to:
$host = $this->options['host'] == 'localhost' ? gethostbyname($this->options['host']) : $this->options['host'];
$this->connection = @mysqli_connect(
$host, $this->options['user'], $this->options['password'], null, $this->options['port'], $this->options['socket']
);
Labels |
Removed:
?
|
Status | New | ⇒ | Closed - Unconfirmed Report |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2015-03-22 14:43:27 |
Closed_By | ⇒ | vdespa |
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2015-03-22 14:43:27 |
Set to "closed" on behalf of @vdespa by The JTracker Application at issues.joomla.org/joomla-cms/6531
I am politly asking to reopen the issue.
Reasons:
a) The code was not understood.
This does not override the user configuration.
if localhost then host = gethostbyname( localhost) is nothing else than what mysql does.
b) changing the hosts file may be possible but is only understood by few. This is a very popular issue, see
http://stackoverflow.com/questions/13439817/why-is-my-mysqli-connection-so-slow/13439864#13439864
I have to agree on this being closed as a config issue. MySQL allows both localhost
and 127.0.0.1
as valid host names and depending on your server configuration may result in different behaviors (i.e. a socket connection versus TCP/IP). Changing the code in Joomla to convert localhost to an IP address always could cause unintended side effects, including changing the manner in which the software connects to the database server.
Items like this should be managed through your local configuration.
Well, then we leave it as it is.
If you like to speed up your local mysql connection, you can use directly socket connection. Edit your configuration.php file and set:
public $host = ':/var/run/mysql/mysql.sock';
Labels |
Added:
?
|
This is a configuration problem, not a Joomla issue. What you are proposing is basically overriding the configuration set by the user. This is not acceptable, in my opinion.
Yes, MySQL can waste time while trying to resolve localhost. You can also add
127.0.0.1 localhost
to your hosts file to speed things up.
Thanks for your report.
This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/6531.