I have this script to get Posts:
$totalrows = 60;
$sql = "SELECT
posts.Tags as tags,
posts.OwnerUserId as postsid,
posts.Id as postid,
posts.Body as body,
posts.Title as title,
users.Id as userid,
users.DisplayName as usersname
FROM posts
JOIN users ON posts.OwnerUserId = users.Id
JOIN (select posts.id from posts where posts.title != '' order by rand() asc limit " . $totalrows .") AS tmp_result
ON (posts.Id = tmp_result.Id)";
$r = mysql_query($sql) or die(mysql_error());
The problem is the server is freezing and require restarting, the mysql file is very large. What causing freezing the server? What can I do to optimize the above query?