我撤回了很多信息,结果我的页面在大约 22~24 秒内加载。我能做些什么来优化我的代码吗?
这是我的代码:
<?php
$result_rules = $db->query("SELECT source_id, destination_id FROM dbo.rules");
while($row_rules = sqlsrv_fetch_array($result_rules)){
$result_destination = $db->query("SELECT pk_id, project FROM dbo.destination WHERE pk_id=" . $row_rules['destination_id'] . " ORDER by project ASC");
while($row_destination = sqlsrv_fetch_array($result_destination)){
echo "Destination project: ";
echo "<span class='item'>".$row_destination['project']."</span>";
echo "ID: ".$row_rules['destination_id']."<br>";
if ($row_rules['source_id'] == null) {
echo "Source ID for Destination ID".$row_rules['destination_id']." is NULL<br>";
} else {
$result_source = $db->query("SELECT pk_id, project FROM dbo.source WHERE pk_id=" . $row_rules['source_id'] . " ORDER by project ASC");
while($row_source = sqlsrv_fetch_array($result_source)){
echo "Source project: ";
echo $row_source['project'];
echo " ID: ".$row_rules['source_id']."<br>";
}
}
}
}
?>
这是我的表的样子:
源表:pk_id:int,project:varchar(50),feature:varchar(50),里程碑:varchar(50),reviewGroup:varchar(125),groupId:int
规则表:pk_id:int、source_id:int、destination_id:int、login:varchar(50)、status:varchar(50)、batchId:int、srcPGroupId:int、dstPGroupId:int
目标表:pk_id:int、project:varchar(50)、feature:varchar(50)、milestone:varchar(50)、QAAssignedTo:varchar(50)、ValidationAssignedTo:varchar(50)、Priority:varchar(50)、groupId :int