MyBB Community Forums

Full Version: searchlog table
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I have one question about the table searchlog in the database. Correct me if i'm wrong: the searchlog table is used to store the "where" clause of the mysql query between the time when the user requests a search and the time when the script search.php does its work.

So i'd like to know if there is any other use of the info stored in that table and if not, would it be possible to delete the search info (ie: the row with the specified sid) after search.php has read it? how?

Thanks Wink
You could put something like this in search.php or in global.php:
$deltime = time() - 3600;
$db->query("DELETE FROM ".TABLE_PREFIX."searchlog WHERE dateline < $deltime");
That would delete any search logs that are more than one hour old. This would allow users to reaccess their search within that time.
ah! ok...

i was thinking about deleting the log as soon as it is read by search.php but if the user clicks reload then it would fail... I think I'll go with your sollution Wink

Thanks!
This is a VERY old post but I just found out today that mybb logs all the searches and doesn't ever prune them. IMHO that's a serious mistake as larger forums will have massive searchlog tables.

At my democracyforums the searchlog table is the 3rd largest table behind posts and privatemessages.

Please...consider using the above code in search to prune anything older than 24 hours. I think this is something that has just slipped between the cracks and was considered low priority but it should be addressed. Forums using mybb are getting bigger and bigger. We don't need a searchlog table that's 5% of the database. Maybe this might be ok to add to the "maintanence" page in admincp.

Lastly...if this doesn't get changed then at LEAST save the keyword that was searched. This would allow me to created a plugin to view the sites top searches and possibly help in SEO and site management.

Please team post your thoughts on a solution and if this is going to be addressed otherwise I will be making a plugin for my sites. However I don't want to waste my time if the mybb team is willing to make alterations to core mybb.
The searchlogs are automatically pruned in 1.4.
hehe...can I get another Amen brother!

Now for that million dollar question...when is 1.4 coming? The anticipation is killing me.
DennisTT Wrote:The searchlogs are automatically pruned in 1.4.

Via the new task system Wink
labrocca Wrote:Now for that million dollar question...when is 1.4 coming? The anticipation is killing me.
When it's done Smile
Oh that's right...the new Task system I have been hearing about. Glad to see it will be used to keep the database clean.