Hello, I am the Webmaster of a german Board Community and I have a problem with an SQL Query.
I have been searching for like a week, but I wasn't able to find a solution for my problem, thats why I have to decided to post my question here.
I use the following query to show the last posts been made on a board ($siteid ist the ID of the Board and $show the number of posts to display):
SELECT
Forum_Posts.dateline,
Forum_Posts.threadid,
Forum_Posts.username,
Forum_Posts.userid,
Forum_Threads.title,
Forum.title as forumtitle,
Forum.forumid,
Forum.viewflag
FROM Forum
LEFT JOIN Forum_Threads using(forumid)
LEFT JOIN Forum_Posts using(threadid)
WHERE Forum.siteid='$siteid' order by dateline desc LIMIT $show
This query is rather slow an it takes about 3-4 Seconds to get the result out of a database of 400.000 posts.
If I remove however the order tag (order by dateline desc) the query becomes really fast.
The explain funtions tells me that mysql hast to use a temporary table and filesort to create the result.
Any suggestions?