需要一些帮助才能加快查询速度。
我创建了一个登录系统但是当我尝试登录时,它需要很慢,我到达目标页面需要将近40秒。
我尝试将MARS的值从0更改为true,仍然没有区别。
请参阅下面的连接字符串代码
$serverName = "10.97.224.56,1433";
$connectionInfo = array("Database"=>"dbtest", "UID"=>"test", "PWD"=>"testpw","MultipleActiveResultSets"=>"1", "MultipleActiveResultSets"=>"true");
$con=sqlsrv_connect($serverName, $connectionInfo);
和查询:
if($result) {
if(sqlsrv_has_rows($result) == 1)
{
//Login Successful
session_regenerate_id();
$member = sqlsrv_fetch_array($result);
$dbactive = $member['active'];
$username = $member['username'];
if ($dbactive==1)
{
$_SESSION['SESS_MEMBER_ID'] = $member['member_id'];
$_SESSION['SESS_USERNAME'] = $member['username'];
$_SESSION['SESS_FIRST_NAME'] = $member['Firstname'];
$_SESSION['SESS_LAST_NAME'] = $member['Lastname'];
session_write_close();
header("location: index.php");
exit();
}
else
echo"<script>alert('Account is inactive. Please contact Admin for account activation.');</script>";
header("Refresh: 0; url=login.php");
die;
我还怀疑sqlsrv_fetch_array
会使查询变慢,我尝试将其更改为sqlsrv_fetch_object
并且也没有任何区别。
有人可以帮我解决这个问题吗?提前谢谢。