PDA

View Full Version : [RELEASE] IndexThread optimization


10-27-2000, 04:13 AM
The index thread function in global.php is another guilty
party of using a while loop to execute queries. This
does away with that. I tested it on my test board with
regular users and guests and all was well.

Find these two lines in global.php and replace it with my code below:

// ###################### Start indexthread #######################


and


// ###################### Start makeforumjump #######################



Insert this code in place


function indexthread($threadid) {
//adds a thread into the search index
global $DB_site;

$thread=$DB_site->query_first("SELECT threadid,title FROM thread WHERE threadid=$threadid");

$subject=$thread[title];

$posts=$DB_site->query("SELECT post.userid, post.username AS guestname, pagetext, user.username AS username
FROM post
LEFT JOIN user ON (user.userid = post.userid)
WHERE threadid=$thread[threadid] AND visible=1");

while ($post=$DB_site->fetch_array($posts))
{
if ($post[userid]!=0)
{
if ($post[username] != "")
{
$usernames.=" $post[username] ";
}
}
else
{
if ($post[guestname] != "")
{
$usernames.=" $post[guestname] ";
}
}
$pagetext.=" $post[pagetext] ";
}

$subject=wordsonly($subject);
$pagetext=$subject." ".wordsonly($pagetext);
$usernames=wordsonly($usernames);

$DB_site->query("UPDATE thread SET subjectindex=' ".addslashes($subject)." ',threadindex=' ".addslashes($pagetext)." ',userindex=' ".addslashes($usernames)." ' WHERE threadid=$threadid");

return 1;
}

10-27-2000, 04:18 AM
[rant]

John should replace the spaces used around the usernames above with commas and then disallow commas as a character in user name.

1 - I could then release the dot hack
2 - Search By User would then work 100%

10-27-2000, 04:25 AM
Also I see where we can optimize index.php but I don't want to touch that until after version 2.0. Hopefully John can do that one..

10-27-2000, 04:50 AM
damn but you're cranking them out hot and heavy!

keep up the good work. So far you have increased my board speed quite a bit :)

10-27-2000, 04:56 AM
This one was a piece of cake compare to the forumjump optimization. The same type of optimization done to forumjump can be done to index.php but it will take a few hours to do and considering it will probably change in v2.0, I want to wait.

10-27-2000, 04:59 AM
the mythical version 2!

I'll give ya a nickle if you do it;)

10-27-2000, 05:06 AM
Originally posted by Martin
damn but you're cranking them out hot and heavy!

keep up the good work. So far you have increased my board speed quite a bit :) yeah.. how many free licenses have you earnt LOL

10-27-2000, 10:00 AM
by the time they are done they will have serveal. :)