The script tested on 2.0.21 - works fine - BUT SLOW!
da_badtz_one wrote:
I would have wished this mod to have been much more efficient. Currenctly it takes 17 seconds to search through a topic which has over 400 replies and over 3500 queries.
man you are right... i somewhat fixed it a bit =) check this code... the script is so badly written it creates a new sql query for each iteration (post)... this makes server load really high and long results.... this is a code snipped digged out around line 388 as i have coded it....
Code: Select all
$search_ids = array();
// Topic Search MOD - by fantomex
// We'll create the list of valid post_ids
if(!empty($tid))
{
$topic_post_ids=array();
$sql = "SELECT post_id
FROM " . POSTS_TABLE . "
WHERE topic_id = '$tid'";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Coudld not find user data', '', __LINE__, __FILE__, $sql);
}
while( $test = $db->sql_fetchrow($result) )
{
$topic_post_ids[]=$test['post_id'];
}
}
// END Topic Search MOD
while( list($post_id, $matches) = each($result_list) )
{
if ( $matches )
{
// Topic Search MOD
if(!empty($tid)) // Pokud je zadan topic id - pokracuj
{
// otestuj, zda-li je aktualni $post_id v seznamu $topic_post_ids[] daneho $tid
if(in_array($post_id,$topic_post_ids) )
{
$search_ids[] = $post_id;
}
$show_results = 'posts';
}
else
{ // End Topic Search MOD
// Topic ID zadan neni a proto jedem normalne
$search_ids[] = $post_id;
// Topic Search MOD
}
// End Topic search MOD
}