Performance Codeigniter, + 2 million records. |
I put some columns as indexes inside MySQL to see if it improves, when I test without calculations or groupings inside the query it ends up being faster, today a table has more than 19 million records and ends up taking an average of 1m each query, today it has around 5/6 graphics to load.
Below is the query that goes faster: $db2->select('SQL_NO_CACHE COUNT( uid ) as totalListeners, DATE_FORMAT(updatedAt, "%d/%m/%Y") as updatedAt'); $db2->where('updatedAt >', $post['date_start']); $db2->where('updatedAt <', $post['date_end']); $db2->where('connecttime <=', $post['timeMax']); $db2->group_by('DATE_FORMAT(updatedAt, "%Y-%m-%d")'); And the query that takes a long time, depending on the number of records, takes more than 3 minutes: SELECT SUM(connecttime) AS connecttime, DATE_FORMAT(updatedAt, '%H:00') as updatedAt FROM listeners WHERE updatedAt>='{$post['date_start']}' AND updatedAt<='{$post['date_end' ]}' AND connecttime >= '{$post['tempoMin']}' GROUP BY HOUR(updatedAt) Thank you very much for the feedback. |
Welcome Guest, Not a member yet? Register Sign In |