mysql - More Waiting time in getting data from database table with large data in PHP -
i have 2 tables 'employee' , 'employeeleaves'. want calculate how many days employee have taken leave year. 'employeeleaves' table have leave details last 3 years. im using adodb.inc.php lib files database connectivity. have 50 employees records , 1000 records of leave taken. application takes approximately 1 minute data , displaying. when see in google chrome->developer tools->network, waiting(ttfb) - 38.46s.
i want reduce time.because once 'employeeleaves' table more data,then waiting time increase. below paste data fetching coding, first take employee list , each employee im calculating leaves particular year.
$employee = new employee(); $employees = $employee->find("1=1"); foreach($employees $employee){ $employeeleave = new employeeleave(); $employeeleaves = $employeeleave->find("employee = ? , leave_period = ? , leave_type = ? , status = ?", array($employeeid,'2016','sickleave','approved')); if(!$employeeleaves){ error_log($employeeleave->errormsg(),true); } return $employeeleaves; }
above code taking 'sickleave', use same ' casual leave' also.
just want know, whether can make query scan rows contain leave period '2016'.
employeeleaves table- field names
+-------------------------------------------------------------------------------------------+ | id, employee, leave_type, leave_period, date_start, date_end, details, status, attachment | +-------------------------------------------------------------------------------------------+
how you?
you have 2 tables, why don't create query join mysql?
it better!
select * employee e inner join employeeleave el on(el.employee = e.id)
Comments
Post a Comment