1

Topic: Slow SQL requests

Today my site was stopped because my forum was taking up too much resources. They said that this was done because of the following requests taking too much time to execute:

use gb_punbb_v0;
SELECT word_id FROM search_matches WHERE word_id IN(17,39,73,86,89,165,248,289,302,333,339,468,478,534,599,776,841,972,1023,1085,1207,1351,2645,3090,3618,3897,4011,4839,5817,6706,7005,7384,9326,10612,10991,11394,12079,13091,14583,14606,16344,17144,17211,17807,19184,20299,20625,24523,37023,37024,47657,51487,51681,62654,69220,69343,75527,79526,79542,82807,84153,90668,90669,90670,90671,90672,90673,90705,90717,90718,90821) GROUP BY word_id, subject_match HAVING COUNT(word_id)=1;

this was 15 seconds,

use gb_punbb_v0;
SELECT u.*, g.*, o.logged, o.csrf_token, o.prev_url, o.last_post, o.last_search FROM users AS u INNER JOIN groups AS g ON g.g_id=u.group_id LEFT JOIN online AS o ON o.ident='72.30.142.82' WHERE u.id=1;

-- 19 sec.

use gb_punbb_v0;
SELECT u.email, u.title, u.url, u.location, u.signature, u.email_setting, u.num_posts, u.registered, u.admin_note, p.id, p.poster AS username, p.poster_id, p.poster_ip, p.poster_email, p.message, p.hide_smilies, p.posted, p.edited, p.edited_by, g.g_id, g.g_user_title, o.user_id AS is_online FROM posts AS p INNER JOIN users AS u ON u.id=p.poster_id INNER JOIN groups AS g ON g.g_id=u.group_id LEFT JOIN online AS o ON (o.user_id=u.id AND o.user_id!=1 AND o.idle=0) WHERE p.topic_id=325 ORDER BY p.id LIMIT 150,25;

-- 24 sec.

Any idea what could be the reason?

My site won't be restarted until the problem is fixed. sad

P.S. Cant' find where the first piece is, the second is in set_default_user() function in functions.php, third in viewtopic.php.

2 (edited by Slavok 2009-06-16 08:16)

Re: Slow SQL requests

First query runs after editing/deleting posts or topics in the function "strip_search_index" (FORUM_ROOT/include/search_idx.php).