我的应用程序使用PHP 5.5和SQL Server从数据库和显示中查询某些记录。
在SQL Server上运行时,此查询大约需要2分钟。
我的问题是mssql_query()
有时会返回NOTHING(即既没有资源ID也没有真或假)。
我预感到这个问题是由于SQL Server超时引起的,但我没有证明这一点,因为我在mssql.timeout = 300
文件中配置了php.ini
(秒)。
有人能帮助我找到根本原因吗?我是php的新手。
SQL查询:
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
SELECT
*
FROM table1 latest
LEFT OUTER JOIN table1 successful
ON latest.MachineVersionID = successful.MachineVersionID
AND successful.BackupToken = (
SELECT TOP 1 BackupToken
FROM table1
WHERE MachineVersionID = successful.MachineVersionID
AND BackupState = 7 AND IsPartial = 0
ORDER BY EndTime DESC
)
INNER JOIN table2 mv ON latest.MachineVersionID = mv.MachineVersionID
INNER JOIN table3 m ON mv.MachineID = m.MachineID
INNER JOIN table4 c ON m.ClientID = c.ClientID
WHERE latest.BackupToken = (
SELECT TOP 1 BackupToken
FROM table1
WHERE MachineVersionID = latest.MachineVersionID
ORDER BY EndTime DESC
)
AND c.PartnerID in (1,2,3,4,5,....)
ORDER BY latest.MachineVersionID
OUTPUT : Return value after executing SQL:
at 11-09-15 04:01:02.189