Improve performance on thread view updating
This modification is in the archives.
Per Doc Erwin:
http://www.vbulletin.com/forum/showpost.php?p=834208&postcount=18 I'm releasing this here. I have a suggestion to improve performance although it is for mysql 4.04 and up (I assume at some point a future version of vb will require it). Requirements: MySQL 4.04 If you have a large forum, run mysql 4.04 and up and want to try this, please report back on your results. The way updating threads views works right now, (even though putting it in cron improved things,) you are still going through many queries to the thread table, potentially locking it up while updating views.The current code from threadviews.php is: PHP Code: PHP Code:
$threads = $DB_site->query("SELECT threadid , COUNT(*) AS views FROM " . TABLE_PREFIX . "threadviews GROUP BY threadid");
With 4.04 you can do a multitable update. FIRST, create the table ONCE ONLY PHP Code: PHP Code:
CREATE TABLE `threadviewsaggregate` (
PHP Code: PHP Code:
$DB_site->query("INSERT INTO ".TABLE_PREFIX ."threadviewsaggregate SELECT threadid , COUNT(*) AS views FROM " . TABLE_PREFIX . "threadviews GROUP BY threadid");
That will reduce the number of queries by however many threads get updated in the cron interval. Additionally, you might be able to skip creating the extra table using subqueries. I haven't gotten around to writing that code yet. If someone wants to add that,mention it in this thread and I'll update the code. Download No files for download. |