{"id":1811,"date":"2005-08-27T21:00:20","date_gmt":"2005-08-28T04:00:20","guid":{"rendered":"http:\/\/www.amptoons.com\/blog\/archives\/2005\/08\/27\/the-recently-commented-post-list\/"},"modified":"2005-08-27T21:00:20","modified_gmt":"2005-08-28T04:00:20","slug":"the-recently-commented-post-list","status":"publish","type":"post","link":"https:\/\/amptoons.com\/blog\/?p=1811","title":{"rendered":"The Recently Commented Post List"},"content":{"rendered":"<p><strong>UPDATE<\/strong>: <em>DreamHost has ordered me to take down the thing entirely. We&#8217;ll just have to do without it until a substitute is found.<\/em><\/p>\n<p>Some &#8220;Alas&#8221; readers may have noticed that comments were down for a while a few days ago. That&#8217;s because the &#8220;Recently Commented Posts&#8221; list on the sidebar was eating too much server time, so the hosting company shut down the comments in self-defense.<\/p>\n<p>I really think some sort of &#8220;recent comments&#8221; post is essential to the discussions we have on &#8220;Alas.&#8221; <strike>As a stopgap measure, I&#8217;ve put the recently commented posts list on a separate page &#8211; you can see the link to it near the top of the sidebar (just below the search box). If you want to see what posts have most recently been updated with new comments, click on that link.<\/p>\n<p>Hopefully, since the &#8220;recently commented&#8221; query will now only be running every time someone goes out of there way to look at it, rather than every single time anyone loads &#8220;Alas&#8221; or any sub-page, this will reduce the server load and allow us to have a &#8220;recently commented&#8221; list while I look for a better solution. (On the other hand, maybe the server load will be too high and Dreamhost will shut the whole website down. It&#8217;s hard to know for sure.)<\/strike><\/p>\n<p>Several people have suggested to me a different sort of &#8220;recently commented posts&#8221; plug-in; one that, instead of doing searches of the (enourmous) comments table every time someone loads a page, automatically wrote to a small table every time a comment was posted, and also deleted the bottom row from the same table. Then the sidebar could just reprint the talble, rather than doing a search of the database. The table would only be updated when people posted new comments, and since it would never be more than 20 or 30 rows in size, it would be very light on the server.<\/p>\n<p>That sounds like a logical solution to me; however, I don&#8217;t know anything about coding at all, so oh well.<\/p>\n<p>Read below the fold if you want to see the recent correspondance about the problem between me and my host. If you understand these matters, please feel free to offer advice. If you know how to code and would be interested in taking a commission to write a better &#8220;recently commented&#8221; plug-in for alas, post or email me and let me know how much you&#8217;d charge. :-)<\/p>\n<pracut>Letter number one, from support to me:<\/p>\n<blockquote><p>Hello,<\/p>\n<p>I&#8217;ve had to disable a mysql query that was running on amptoon that was bringing &#8220;juno&#8221; to its knees.  Here is the query:<\/p>\n<p># Time: 050825 10:30:57<\/p>\n<p># User@Host: verbosity[verbosity] @ scipio.dreamhost.com [205.196.218.27]<\/p>\n<p># Query_time: 36  Lock_time: 0  Rows_sent: 8  Rows_examined: 82479<\/p>\n<p>SELECT alas_posts.*, MAX(comment_date) AS max_comment_date FROM<br \/>\nalas_comments, alas_posts WHERE alas_posts.post_date <= '2005-08-25\n10:29:51' AND ( alas_posts.post_status = 'publish' OR\nalas_posts.post_status = 'sticky' ) AND alas_posts.post_password = '' AND\nalas_posts.ID = alas_comments.comment_post_ID AND\nalas_comments.comment_approved = '1' GROUP BY alas_posts.ID ORDER BY\nmax_comment_date DESC LIMIT 0, 8;\n\nUnfortunately, I can't just disable a query.  So I renamed your alas_comments to alas_comments_disabled_by_dreamhost.  (That query is unindexable too.  Please learn about the EXPLAIN statement.)\n\nOnce you've prevented that query from ever running again, you can rename the table back.  If you decide to run that query again, we'll have to disable your entire database permanently.\n\nThanks!\n\nJason<\/p><\/blockquote>\n<p>Then I wrote back to Jason. Actually, I wrote back to Jason a few times, but once I had a non-angry reply I actually emailed it rather than throwing it away. :-)<\/p>\n<blockquote><p>I think that I&#8217;ve disabled the plug-in that was causing the query, but it&#8217;s hard for me to be 100% certain. However, I&#8217;m 90% certain that I&#8217;ve shut down the right thing.<\/p>\n<p>Rather than permanently disabling my database if the query occurs again (which is a nicer way for you to say, &#8220;I&#8217;ll permanently kill your website&#8221;), please rename the alas_comments file again, and I&#8217;ll do my best to get the problem solved. But I really think I have solved the problem, so unless I&#8217;ve completely misdiagnosed the problem, it won&#8217;t come up at all.<\/p>\n<p>Can you give me an idea about the nature of the problem. For example, is it that the query itself is too horrible to run, or is the problem that it&#8217;s running too often (e.g., if the same query ran a few dozen times a day, rather than hundreds of times a day, would that still force you to pull the plug on my website?)<\/p>\n<p>Could you give me any more details about the problem (logs, etc) so I could try and find a way to have my website be fully functional without messing you folks up?<\/p>\n<p>Thanks,<\/p>\n<p>Barry<\/p><\/blockquote>\n<p>And, finally, I recieved this response from Jason:<\/p>\n<blockquote><p>> Rather than permanently disabling my database if the query occurs<br \/>\n> again (which is a nicer way for you to say, &#8220;I&#8217;ll permanently kill<br \/>\n> your website&#8221;), please rename the alas_comments file again, and I&#8217;ll<br \/>\n> do my best to get the problem solved. But I really think I have solved<br \/>\n> the problem, so unless I&#8217;ve completely misdiagnosed the problem, it<br \/>\n> won&#8217;t come up at all.<\/p>\n<p>You&#8217;ve got it!  If you&#8217;re making efforts to find it, and you&#8217;re basically sure you&#8217;ve already nailed it, that sounds great to me.  Go ahead and rename it back, and if it pops up again, I&#8217;ll rename the table again. I&#8217;m sure you&#8217;ll understand that I can&#8217;t do this ad infinitum.<\/p>\n<p>> Can you give me an idea about the nature of the problem. For example,<br \/>\n> is it that the query itself is too horrible to run, or is the problem<br \/>\n> that it&#8217;s running too often (e.g., if the same query ran a few dozen<br \/>\n> times a day, rather than hundreds of times a day, would that still<br \/>\n> force you to pull the plug on my website?)<\/p>\n<p>Sure!  The query was running a lot (several times a minute?  maybe a lot more than that?), it was examining more than 80,000 rows (you should shoot for less than 5000; see the EXPLAIN statement), and quite importantly, it was taking 36 seconds (should take less than one second).<\/p>\n<p>Unfortunately, the logs are difficult to provide to users on a regular basis, as they&#8217;re all mixed in together&#8230;.<\/p>\n<p>Good luck with debugging!<\/p><\/blockquote>\n<p>And that&#8217;s where it stands.<\/p>\n<p>The plug-in I&#8217;m currently using is <a href=\"http:\/\/www.coffee2code.com\/archives\/2004\/08\/27\/plugin-customizable-post-listings\/\">Customizable Post Listings<\/a>, which I&#8217;m told by an expert doesn&#8217;t have a greater server load than the other post-listing plugins available. If anyone out there knows how to modify CPL so that it examines less than 5,000 rows, that would be cool.<\/pracut>\n","protected":false},"excerpt":{"rendered":"<p>UPDATE: DreamHost has ordered me to take down the thing entirely. We&#8217;ll just have to do without it until a substitute is found. Some &#8220;Alas&#8221; readers may have noticed that comments were down for a while a few days ago. &hellip; <a href=\"https:\/\/amptoons.com\/blog\/?p=1811\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[98],"tags":[],"class_list":["post-1811","post","type-post","status-publish","format-standard","hentry","category-site-and-admin-stuff"],"_links":{"self":[{"href":"https:\/\/amptoons.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1811","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/amptoons.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/amptoons.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/amptoons.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/amptoons.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1811"}],"version-history":[{"count":0,"href":"https:\/\/amptoons.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1811\/revisions"}],"wp:attachment":[{"href":"https:\/\/amptoons.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1811"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/amptoons.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1811"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/amptoons.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1811"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}