MyBB Community Forums

Full Version: Slow duplicate post detection
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Since it is suggested that suggestions are posted in this forum, so that it can be ignored and just die in oblivion, I thought it'd be harmless to put another one.

The duplicate post check in new thread is very slow as it looks for every post by a user (and ironically enough, can be the cause of duplicate threads)
	if(!$mybb->input['savedraft'] && !$pid)
	{
		$query = $db->simple_select("posts p", "p.pid", "$user_check AND p.fid='{$forum['fid']}' AND p.subject='".$db->escape_string($mybb->input['subject'])."' AND p.message='".$db->escape_string($mybb->input['message'])."' AND p.posthash='".$db->escape_string($mybb->input['posthash'])."'");
		$duplicate_check = $db->fetch_field($query, "pid");
		if($duplicate_check)
		{
			error($lang->error_post_already_submitted);
		}
	}

I would imagine a key on uid,fid,posthash should be enough most of the time (and possibly ipaddress instead of uid if you care about guest posting).
Similar story for newreply, but it's not as big an issue because the search is limited to a thread.
I think this was one of the first things I did on 1.8. I thought I had replied to your previous thread but obviously not.
(2012-08-02, 08:17 AM)Tomm M Wrote: [ -> ]I thought I had replied to your previous thread but obviously not.
Great - now I have a nigh permanent thread I can always refer back to with the suggestions policy XD

Thank you.