mysql空间速度慢
答案
请教大家一个问题,我花钱租了个mysql的服务器虚拟空间,发现速度很慢。我用最简单的表格查询,每查询一次都要用5秒钟以上,这正常吗?
数据库里,只有一个表格和两条记录,
下面是我的测试代码:
$stime = microtime(true); // 获取程序开始执行的时间
$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['名称'] . "|" . $row['数量'] . "
";
}
mysql_close($cn);
$etime = microtime(true); // 获取程序执行结束的时间
$total = $etime - $stime; // 计算差值
echo "(mysql版)此次查询执行时间:" . $total . "秒";
?>
复制代码
最佳答案[url=http://www.phpchina.com/bbs/space.php?username=Fising]链接标记Fising[/url]
[url=http://www.phpchina.com/bbs/space.php?uid=31544]链接标记[img]http://www.phpchina.com/server/avatar.php?uid=31544&size=small[/img][/url]网络连接开销太大了。数据库和WEB最好在一个机器,不行最好是在一个局域网也可以。
其它解决方案
网络连接开销太大了。数据库和WEB最好在一个机器,不行最好是在一个局域网也可以。
其它解决方案
楼上所言极是
其它解决方案
是这样的。很多主机甚至不支持远程连接的
其它解决方案
中国数据的服务器吧~这台服务器都已经坏了,呵呵
服务器负载太高造成的
其它解决方案
换空间 找个好点的
其它解决方案
多谢大家啦,问题解决。[img]http://www.phpchina.com/bbs/images/smilies/default/victory.gif[/img]
的确是中国数据的服务器啦.[img]http://www.phpchina.com/bbs/images/smilies/default/sleepy.gif[/img]
估计就是Fising说的数据库和PHP不在一台服务器的原因,让他们把数据库空间和php空间弄到同一台服务器上,速度就快了。
其它解决方案
[img]http://www.phpchina.com/bbs/images/smilies/default/shocked.gif[/img]

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

Zend Studio 13.0.1
Powerful PHP integrated development environment

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),
