使用 mssql 时页面加载结束时的延迟
我在 Windows 2003、SQL Server 2008 Express 上安装了可以正常工作的 mssql、php。我终于使连接正常工作了,但是现在与数据库的连接确实很快,但断开连接很慢。即使所有页面在几毫秒内加载完毕,这也会使页面的最终加载延迟大约 5 秒。
我认为这与 php/mssql 没有快速释放与数据库的连接有关。这里的主要问题是我的 javascript yui 脚本在页面认为已完全加载之前不会运行。
我已经尝试立即关闭连接,但我不需要它,但没有效果。
有人知道我可以设置什么设置来修复它吗?
I have a working installation of mssql, php on Windows 2003, SQL Server 2008 express. I finally got the connection working right, but now the connection to the database is really quick but its disconnection is slow. This delays the final loading of my page by about 5 seconds, even though all the page is loaded in a few milliseconds.
I think this is something to do with php/mssql not releasing the connection to the database quickly. The main problem here is that my javascript yui scripts wont run until the page thinks its fully loaded.
I've tried closing the connection immediately I don't need it to no avail.
Anyone know what setting I could set to fix it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您始终可以调用 PHP flush() 函数来使脚本生成的任何内容仍然是 PHP 或要刷新的 Apache 缓冲区。
另外,如果您使用 mssql_pconnect 建立与 MS SQL 数据库的持久连接,则当PHP 脚本存在,所以我想 mssql_close 将不再保留您的脚本。
You can always call PHP flush() function to make any content generated by the script that is still in PHP or Apache buffer to be flushed.
Also, if you used mssql_pconnect to establish persistent connections to the MS SQL database, the connection is never closed when the PHP script exists, so I suppose mssql_close will not hold your script anymore.
我认为问题出在 DNS 条目不正确。我更改了服务器正在检查的上游 DNS 服务器,延迟消失了。
I think the problem turned out to be incorrect DNS entries. I changed the upstream DNS server being checked by the server and the lag went away.