Loading time is very much for code igniter web page
<p>I am using Code igniter frame work and i found too much loading time for a page.The other pages are normal speed and when i used the profiler for the slow page i found the following result: </p>

<pre><code>**BENCHMARKS  
Loading Time: Base Classes      0.0090
Controller Execution Time ( Home / Index )      3.6712
Total Execution Time    3.6802
MEMORY USAGE  
7,404,176 bytes
DATABASE:  db202519_sdemo   QUERIES: 244**  

&lt;?php 
function getAllAd_bymotorcars($serach_data,$order,$limit = '',$offset = ''){
    $twoMonths=strtotime("-3 months", time());
    $this-&gt;db-&gt;cache_on();
        $q  = ' SELECT * FROM place_ad';
        if(isset($serach_data['photos']) &amp;&amp; $serach_data['photos'] !=""){       
        $q .= ' JOIN place_ad_gallery ON place_ad.id_place_ad = place_ad_gallery.id_place_ad';
        }
        $q .= ' WHERE place_ad.deleted = 0 AND place_ad.status = "active"';
        $q .= ' AND place_ad.id_sub_categories  = 1';
        $q .= ' AND place_ad.id_categories  = 1';

    if(isset($serach_data['countries']) &amp;&amp; $serach_data['countries'] !=""){
     $q .= ' AND place_ad.id_countries  = '.$serach_data['countries'];  
    }   
    if(isset($serach_data['cities']) &amp;&amp; $serach_data['cities'] !=""){
        $q .= ' AND place_ad.id_cities  = '.$serach_data['cities']; 
    }
    if(isset($serach_data['area']) &amp;&amp; $serach_data['area'] !=""){
        $q .= ' AND place_ad.id_area  = '.$serach_data['area']; 
    }
    if(isset($serach_data['sub_categories']) &amp;&amp; $serach_data['sub_categories'] !=""){
        $q .= ' AND place_ad.id_sub_categories  = '.$serach_data['sub_categories']; 
    }
    if(isset($serach_data['sub_categories2']) &amp;&amp; $serach_data['sub_categories2'] !=""){
        $q .= ' AND place_ad.id_sub_categories2  = '.$serach_data['sub_categories2'];   
    }
    if(isset($serach_data['sub_categories3']) &amp;&amp; $serach_data['sub_categories3'] !=""){
        $q .= ' AND place_ad.id_sub_categories3  = '.$serach_data['sub_categories3'];   
    }
    if((isset($serach_data['price_from']) &amp;&amp; $serach_data['price_from'] !="") &amp;&amp; (isset($serach_data['price_to']) &amp;&amp; $serach_data['price_to'] !="")){
        $q .= ' AND place_ad.price_aed  BETWEEN  '.$serach_data['price_from'].' AND '.$serach_data['price_to']; 
    } else{
    if(isset($serach_data['price_from']) &amp;&amp; $serach_data['price_from'] !=""){
        $q .= ' AND place_ad.price_aed  &gt;=  '.$serach_data['price_from'];   
    }
    if(isset($serach_data['price_to']) &amp;&amp; $serach_data['price_to'] !=""){
        $q .= ' AND place_ad.price_aed  &lt;= '.$serach_data['price_to'];  
    }
    }
    if(isset($serach_data['adress_ad']) &amp;&amp; $serach_data['adress_ad'] !=""){
        $adress_ad=$serach_data['adress_ad'];
        $q .= " AND place_ad.title LIKE '%$adress_ad%'";    
    }
    if(isset($serach_data['age']) &amp;&amp; $serach_data['age'] !=""){
        $q .= ' AND place_ad.age  = '.$serach_data['age'];  
    }

    if(isset($serach_data['condition']) &amp;&amp; $serach_data['condition'] !=""){
        $q .= ' AND place_ad.condition  = '.$serach_data['condition'];  
    }
        if(isset($serach_data['warranty']) &amp;&amp; $serach_data['warranty'] !=""){
        $q .= ' AND place_ad.warranty  = '.$serach_data['warranty'];    
    }
    if(isset($serach_data['ads_posted']) &amp;&amp; $serach_data['ads_posted'] !=""){
$date_to = date('Y-m-d');

$date_from = strtotime(date('Y-m-d'));
$case = $serach_data['ads_posted'];
switch($case) {
    case 0:
        $date_from = strtotime('0 days',$date_from);
        break;
    case 3:
        $date_from = strtotime('-3 days',$date_from);
        break;
    case 7:
        $date_from = strtotime('-7 days',$date_from);
        break;
    case 14:
        $date_from = strtotime('-14 days',$date_from);
        break;
    case 30:
        $date_from = strtotime('-30 days',$date_from);
        break;
    case 90:
        $date_from = strtotime('-90 days',$date_from);
        break;
    case 190:
        $date_from = strtotime('-190 days',$date_from);
        break;
}
$date_from = date('Y-m-d',$date_from);  
     $q .= ' AND place_ad.created_date &gt;= "'.$date_from.'" AND place_ad.created_date &lt;= "'.$date_to.'"';
    }
        if(isset($serach_data['photos']) &amp;&amp; $serach_data['photos'] !=""){       
        $q .= ' AND place_ad_gallery.image!=""  ';  
        }
        //$q .= ' GROUP BY place_ad.id_place_ad';
        if(isset($serach_data['photos']) &amp;&amp; $serach_data['photos'] !=""){       
        $q .= ' GROUP BY  place_ad_gallery.id_place_ad';
        }
        $q .= ' ORDER BY  '.$order;
    if($limit != '')
    $q .= ' LIMIT '.$limit.' OFFSET '.$offset;
    $query = $this-&gt;db-&gt;query($q);
    //echo $this-&gt;db-&gt;last_query();exit;
        if($limit == '')
        return $query-&gt;num_rows();
        else
        return $query-&gt;result_array();
}
?&gt;
</code></pre>

<p>The above function used in the controller to fetch all these info.While passing through the function the page faces the loading issue.</p>

<p>How can i increase the loading speed for this page?</p>