![]() |
Improve performance on thread view updating
Per Doc Erwin:
http://www.vbulletin.com/forum/showp...8&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:
With 4.04 you can do a multitable update. FIRST, create the table ONCE ONLY PHP Code: PHP Code:
PHP Code: PHP Code:
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. |
put your codes in [ PHP ] tags please...
also, can you point a real MySQL doc where the example is explained and rated ?!... because i can see your point, as a mysql developper, but many others will discuss it... |
I copied it from vb.com and on preview the php code displayed. I edited it.
On the mysql: http://dev.mysql.com/doc/mysql/en/update.html Quote:
|
ok, no problem btw...
but i would usggest you to release it in the BETA forum instead, because it's in development, not really releaseable on production sites... but maybe you can modify it to have a if statement depending on PHP version we have on our server... |
Quote:
This hack doesn't depend on PHP version, only on MySQL version - anything greater than 4.0 works. My changes are: 1. This string has a typo, there should be a space after "FROM" PHP Code:
PHP Code:
http://www.vbulletin.com/forum/showp...4&postcount=16 |
Quote:
|
Quote:
PHP Code:
|
I encouraged dwh to post here. :) It's fine to be in this forum, no need to be in beta considering it's working on some large sites.
I may add this to my forum with over 14mil posts... I am always wary of database corruption. :) |
Quote:
You deserve a beer. Can you PM me your url? Would love to take a look. |
Erwin's forum is very large :)
I have this running on my home box with no problems, probbly use this on my production site soon to. :) |
This does look very promising, has jelsoft thought about integrating it into the product?
|
Yes they are.
I haven't had a chance to develop it yet but using the same principle Ibelieve there are a couple of other places this concept can be used. |
Thats great news. Now if I can only work up the nerve to upgrade to 3.1.0 when it comes out :)
|
Quote:
|
Installed this and got this error after sometime:
PHP Code:
|
Is the lack of spaces only coming from your post or is it in your code as well? And what version of mysql do you have installed?
|
good questions.
|
will certainly give it a go ..:)
|
Quote:
PHP Code:
|
Indeed you need to space your query out - that's why it's not working :)
|
For some reason, lately when I post here, the spaces get pulled out and words are stuck together. I have no idea why.
|
I just installed this... so far so good :cool:
|
did the edits keep getting this
Code:
Database error in vBulletin 3.0.7: |
nevermind!
this is the correct code... Code:
error_reporting(E_ALL & ~E_NOTICE); |
Hi, and first of all thank you for this release.
I was just wondering if it is normal that the "threadviewsaggregate" table remains empty ? |
Quote:
|
Ok, thanks for the answear ;)
|
How about a downloadable text file with edits @ instructions???
|
So, is the best code in the first post, or am I supposed to use one of the other users contributions?
Also, I am running mySQL 4.0.24. Will this work with my version? Thanks! |
Okay, I'd like to try this, but AdminCP says I don't have permission to execute queries. I tried pasting the create table stuff into the MySQL command box, but it said I needed to specify a datavase. I don't know the sytax so I couldn't.
A little help here please. |
To run a query in your ACP, you must add your userid to the canrunquery variable in your config.php
|
And this is the correct code?
Quote:
|
Okay, I put that code in and turned on logging. It says it ran fine.
Thanks for the help. |
Quote:
Database error in vBulletin 3.0.6: Invalid SQL: INSERTINTOthreadviewsaggregate SELECT threadid , COUNT(*)ASviewsFROM threadviews GROUP BY threadid mysql error: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'INSERTINTOthreadviewsaggregate SELECT threadid , COUNT(*)ASview mysql error number: 1064 Date: Saturday 21st of May 2005 10:56:17 AM Script: http://forums.pimprig.com/cron.php?&rand=634959 Referer: http://gallery.pimprig.com/showphoto...o=2553&cat=501 Username: Unregistered IP Address: 86.133.1.23 |
Insert spaces where needed. The code in this thread is somehow missing some spaces.
Edit: Edited the original code now with spaces inserted. |
Took long enough...
But not all occurences are updated: Code:
query("SELECTthreadid , |
Quote:
Quote:
|
Sorry, I thought you're author of this hack but I see my mistake now.
|
Installed on AVS Forum.
|
I see this has been installed successfully a few places. Anyone willing to comment on performance improvements they've notice?
-Mel |
All times are GMT. The time now is 02:46 AM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|