I am working on a laundry management system and want to retrieve customer order details with customer name from two tables having 25000+ rows of data. My code is working fine but using joins its taking too long to fetch the result. Kindly help me optimize the query. thanks here goes my code that works fine buts takes more than a minute to return the data and almost crashes most of the time...
$this->db->select('users.first_name,customer_order.auto_id, customer_order.invoice_no, customer_order.order_date, customer_order.order_place_from, customer_order.customer_id, customer_order.total_qty, customer_order.discount, customer_order.disc_amt, customer_order.total_paid, customer_order.total_balance, customer_order.delivery_date, customer_order.amt_paidby, customer_order.order_status, customer_order.mode_of_payment_adv, customer_order.advance_paid, customer_order.mode_of_payment_bal, customer_order.balance_paid_date');
$this->db->from('customer_order');
$this->db->join('users', 'customer_order.customer_id=users.id');
$this->db->order_by("auto_id","desc");
$data['invoiceorder'] = $this->db->get()->result();
Limiting the record gives accurate timing but I need to fetch all records