如何减少php脚本的加载时间

I am taking lat, lng from mysql and load the map. But in this iteration 1000's of data loading for drawing route on map but for this process it takes too long time. After loading the code it takes 30 sec and above so please help me how to reduce the loading time of this script Thanks

<?php
    $result=mysql_query("select * from marker1 where  date='$maxdate' and time BETWEEN '$mintime' AND '$maxtime' and imei_no='$vehicle_imei_no1'")or die(mysql_error());

    $markers =new SimpleXMLElement('<markers/>');//Create SimpleXMLElement object
    while($row = mysql_fetch_assoc($result)){ //Add each column value a node of the XML object
    $marker = $markers->addChild('marker');
    $marker->addChild('lat',$row['lat']);
    $marker->addChild('lng',$row['lng']);
    $marker->addChild('date',$row['date']);
    $marker->addChild('time',$row['time']);
    $marker->addChild('speed',$row['speed']);
    $marker->addChild('vehicle_status',$row['vehicle_status']);

    array_push($lat_lng,$row['lat'],$row['lng']);

    if($row['vehicle_status']=='M' && $row['speed'] >3){
    array_push($allTime,$row['time']);
    }else {
    array_push($allTime,-1);
    }

    if($row['vehicle_status']=='M' && $row['speed'] <= 3 ){
    array_push($parkedTime,$row['time']);
    }else {
    array_push($parkedTime,-1);
    }

    }

      $fp=fopen('genxml.xml','wb'); //Create the XML file
      fwrite($fp,$markers->asXML());      //Write the XML nodes
      fclose($fp);  
    include 'currentlocation1.php';

    ?>