mysql space is slow_PHP tutorial

WBOY
Release: 2016-07-13 10:53:51
Original
843 people have browsed it




mysql space is slow
Answer


Let me ask you a question. I spent money to rent a MySQL server virtual space and found that the speed was very slow. I use the simplest form to query, and each query takes more than 5 seconds. Is this normal?

There is only one table and two records in the database,
Below is my test code:

$stime = microtime(true); // Get the time when the program starts execution

$db_ip = "61.152.93.83";

$db_user = 'blinnes';

$db_pass = 'ji64Edfw2';

$cn = mysql_connect($db_ip, $db_user, $db_pass);

$db = mysql_select_db("blinn");

$sql = "select * from `test`";

mysql_query("set names gb2312");

$rs = mysql_query($sql);

while ($row = mysql_fetch_array($rs))

{

echo "mysql! - " . $row['name'] . "|" . $row['quantity'] . "
";

}

mysql_close($cn);

$etime = microtime(true); // Get the time when program execution ends

$total = $etime - $stime; // Calculate the difference

echo "(mysql version) execution time of this query:" . $total . "seconds";

?>


Copy code


Best answer[url=http://www.phpchina.com/bbs/space.php?username=Fising]Link tag Fising[/url]
[url=http://www.phpchina.com/bbs/space.php?uid=31544]Link tag[img]http://www.phpchina.com/server/avatar.php?uid=31544&size=small[ /img][/url]The network connection overhead is too high. It is best for the database and WEB to be on the same machine. If not, it is better to be on a local area network.



Other solutions
The network connection overhead is too high. It is best for the database and WEB to be on the same machine. If not, it is better to be on a local area network.

Other solutions
What is said above is absolutely true

Other solutions
That's it. Many hosts don’t even support remote connections

Other solutions
China Data’s server~ This server is broken, haha

Caused by high server load

Other solutions
Change space and find a better one

Other solutions
Thank you all, the problem is solved. [img]http://www.phpchina.com/bbs/images/smilies/default/victory.gif[/img]
It is indeed a Chinese data server.[img]http://www.phpchina.com/bbs/images/smilies/default/sleepy.gif[/img]
This is probably why Fising mentioned that the database and PHP are not on the same server. It will be faster if they put the database space and PHP space on the same server.

Other solutions
[img]http://www.phpchina.com/bbs/images/smilies/default/shocked.gif[/img]


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/632378.htmlTechArticlemysql space is slow answer I would like to ask you a question. I spent money to rent a mysql server virtual space and found the speed Very slow. I use the simplest form to query, and use it every time I query...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template