My query is running in php myadmin withing few seconds and getting time exceeds in code igniter
<p>Following are the query which is executed:</p>

<pre><code>select esd.voucher_id, esd.qty,esd.rate,esd.str_percentage,esd.cur_inr, v.voucher_date, v.bill_no, v.currency,dbk.p_voucher_id,v.voucher_type, v.bill_pass_amt as amount_fc, v.exc_rate, v.amount_inr, v.payment_voucher,dbk.p_voucher_id,pre.inviceno,(select sum(amount) from rkisexport.preshipmentindex where inviceno=v.bill_no) as Total,intable.voucher_id as invoucher_id,intable.voucher_date as invoucher_date,intable.amount_inr as  stramt,intable.p_voucher_id as inpayment_voucher,intable.amt_settled_inr as amt_inr,intable.cheque_no,intable.ctdate,intable.cheque_tt,intable.tt_no,bdatetab.voucher_date as brvoucher_date from export_sales_details esd 
    join voucher v on esd.voucher_id = v.voucher_id
    left join dbk_str_received dbk on v.voucher_id = dbk.voucher_id
    left join preshipmentindex pre on pre.inviceno = v.bill_no
    left join (select vo.voucher_id,vo.bill_no,vo.voucher_settled,vo.voucher_date,vjo.amount_inr,vpd.p_voucher_id,vp.tt_no,vp.cheque_tt,vp.cheque_no,vp.ctdate,IFNULL((select sum(received) from dbk_str_received where p_voucher_id in(select voucher_id from voucher where voucher_date &lt;= '".$to."' and voucher_id in(select p_voucher_id from dbk_str_received where voucher_id=vo.voucher_id  and type = '6456')) and voucher_id=vo.voucher_id and type='6456'),0) as amt_settled_inr from voucher vo join voucher_journal vjo on vjo.voucher_id=vo.voucher_id left join dbk_str_received vpd on vpd.voucher_id=vo.voucher_id left join voucher_payment_detail vp on vp.voucher_id=vpd.p_voucher_id where vo.voucher_type='IN' and vjo.account_code='6456') intable on intable.bill_no=v.bill_no
    left join (select voucher_date,voucher_id from voucher) bdatetab on bdatetab.voucher_id=intable.p_voucher_id
    where esd.str_applicable =1 and v.voucher_type = 'ES' and v.company_id in ( 'RKR' ) and v.voucher_date &gt;= '".$from."' and v.voucher_date &lt;= '".$to."'  group by esd.voucher_id order by ".$sortBy."
</code></pre>