Hi,
I've got the query below to find all posts for a tag. It takes often a minute or just times out as it can be searching through hundreds of threads even though it's limited to a few results.
Will some indexes make it perform at a decent speed? Or is it a problem with my amateur coding?
I've got the query below to find all posts for a tag. It takes often a minute or just times out as it can be searching through hundreds of threads even though it's limited to a few results.
Will some indexes make it perform at a decent speed? Or is it a problem with my amateur coding?
Code:
$threadidz = $db->fetchAll("SELECT th.thread_id FROM `xf_tag_content` as tc, xf_tag as t, xf_thread as th
where tc.content_type = 'thread'
and t.tag_id = tc.tag_id
and th.thread_id = tc.content_id
and t.tag_id =" . $tag['tag_id']);
$threadidzz = $db->quote($threadidz);
$postRepo = $this->getPostRepo();
$postList = $postRepo->finder('XF:Post');
$postList
->where('reaction_score', '>=', 100)
->whereSql("xf_post.thread_id IN ($threadidzz)")
->setDefaultOrder('reaction_score', 'DESC');