I have a table that has 600000 rows. I found that Grocery Grud very slow. I examined the code and I found the slow part on grocery_grud_model.
Line 178
function get_total_results() { //set_relation_n_n special queries. We prefer sub queries from a simple join for the relation_n_n as it is faster and more stable on big tables. if(!empty($this->relation_n_n)) { $select = "{$this->table_name}.*"; $select = $this->relation_n_n_queries($select); $this->db->select($select,false); } return $this->db->get($this->table_name)->num_rows(); }
To get the total count, script gets all result. I changed the code like below.
function get_total_results() { //set_relation_n_n special queries. We prefer sub queries from a simple join for the relation_n_n as it is faster and more stable on big tables. if(!empty($this->relation_n_n)) { $select = $this->relation_n_n_queries($select); } return $this->db->from($this->table_name)->count_all_results(); }
Performance is good now.