[eluser]Bainzy[/eluser]
Hey everyone,
Right I have run into a little issue while I am trying to profile Dove Forums.
Basically the front page is currently made up of 18 queries, all less than 1 millisecond, however 10 of these queries are to retrieve the amount of reply's to a topic.
What I have done is created a helper for general forum functions and counting the amout of reply's is on of my functions, so here is the function in the helper file :
Code:
function countComments($TopicID)
{
$CI=& get_instance();
return $CI->MTopics->countComments($TopicID);
}
and here is the code in my model file :
Code:
function countComments($TopicID)
{
$options = array('TopicID'=>$TopicID, 'Active'=>'1');
$query = $this->db->get_where('comments', $options);
return $query->num_rows();
}
What i need to know is there any other way of counting the topics rather then running 10 queries, as my concern is say there is 10,000 topics in the database, the above code is going to be executed 10,000 times just to get a number back ?
Any help on this guys ?