简体   繁体   English

MSSQL/PHP:mssql_select_db() 在某些数据库上需要 2 秒

[英]MSSQL/PHP: mssql_select_db() takes 2 seconds on certain database

I have just noticed one of my MSSQL databases has slowed down dramatically.我刚刚注意到我的一个 MSSQL 数据库的速度急剧下降。 The weird thing is, it's the smallest database of them all but it takes the longest to open.奇怪的是,它是所有数据库中最小的,但打开时间最长。

After the database opens using mssql_select_db() it queries fine, but the initial mssql_select_db() takes 2 seconds.使用 mssql_select_db() 打开数据库后,它查询正常,但初始 mssql_select_db() 需要 2 秒。 What could possibly be causing this?这可能是什么原因造成的?

Database 1 is much larger and has many more tables/rows then Database 2, they are both on the same MSSQL server so it's not a networking issue.数据库 1 比数据库 2 大得多,并且有更多的表/行,它们都在同一个 MSSQL 服务器上,所以这不是网络问题。

Database 1
Connection/Selecting DB Time: 0.00554800033569
Query Time: 0.035463809967

Database 2 (Slow One)
Connection/Selecting DB Time: 2.40434789658
Query Time: 0.144586801529

Update: When i have "Database 2" open in Server Management Studio.更新:当我在 Server Management Studio 中打开“数据库 2”时。 mssql_select_db() seems to run normally, and connects fast see below mssql_select_db() 似乎运行正常,连接速度快见下文

Database 1
Connection/Selecting DB Time: 0.00480604171753
Query Time: 0.0346729755402

Database 2 (Slow One)
Connection/Selecting DB Time: 0.00085186958313
Query Time: 0.0340950489044

This is not caused by too many active connections, I have already ruled that out.这不是活动连接过多造成的,我已经排除了。 Any ideas?有任何想法吗?

Update 2: I'm running PHP Version 5.2.6-1+lenny13 using MSSQL FreeTDS Library.更新 2:我正在使用 MSSQL FreeTDS 库运行 PHP 版本 5.2.6-1+lenny13。 I am directly connecting via IP not using hostnames so it's not a resolv issue.我通过 IP 直接连接,不使用主机名,所以这不是解决问题。

Could it be that other processes have open connections to that DB and there are no other available available connections?可能是其他进程与该数据库有打开的连接并且没有其他可用的可用连接吗?

I have rebuilt the database and re-imported all the data, that has seemed to fix the problem.我已经重建了数据库并重新导入了所有数据,这似乎解决了问题。 It may have just have been database fragmentation this whole time.它可能一直都是数据库碎片。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM