The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
Unoptimized query
is below query normal it sometimes takes 27 seconds on some big forum sections which kills performance like crazy
from what i understand it only counts number of threads in certain forums yes there are alot of threads on my forum but is there anything i can do to optimize this query, there is 1 more but i can live with the other. Somehow i feel like noone can help me. PHP Code:
|
#2
|
||||
|
||||
How many threads are we talking? Also where did you pull that query from?
|
#3
|
||||
|
||||
forumdisplay.php line 720 in 3.8.4.
|
#4
|
||||
|
||||
I don't have a copy of vB's database handy to check, so check this index doesn't already exist. Try creating an index on the thread table with these fields in this order:
INDEX(forumid, sticky, visible) Saying that, that query shouldn't be be particularly show. Can you also paste the full profiling output. |
#5
|
|||
|
|||
The query is already using that index, according to EXPLAIN in the first post:
Code:
id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE thread range forumid forumid 6 119685 Using where I'm afraid nothing could be done from the vBulletin side of things. Maybe some MySQL server tweaking will help to speed up that query. |
#6
|
||||
|
||||
Quote:
Code:
KEY forumid (forumid, visible, sticky, lastpost), |
#7
|
||||
|
||||
All code optimizations aside, you could edit this forum so it only shows threads from the past 6 months or year instead. This should significantly reduce the # of threads and still utilize the index.
|
#8
|
|||
|
|||
Oh yes.
Hopefully the default sort order for that forum is by the last post time, otherwise the index wouldn't work. |
#9
|
|||
|
|||
thanks so much for the replies , i think i understand the solution from the replies
i am on it right now that forumid had 120.000 threads --------------- Added [DATE]1253994808[/DATE] at [TIME]1253994808[/TIME] --------------- i could only do siradrian's solution and it works. Do you think this mod will help me with only single query https://vborg.vbsupport.ru/showthread.php?t=210897 it looks a little hard. |
#10
|
||||
|
||||
Afraid not. That mod is just to help automate common administrative queries. The easiest solution to implement is changing the option I mentioned above.
If you do not want to do that (and honestly I don't see why not...) then here is my thought.... Why on earth would you want to browse through 120,000 threads? The data does not get lost; you can still search and find it. I don't see people going past about 5-10 pages. Maybe 20 if they are bored. People use searching. If your forum is that busy, where you cannot restrict posts by the past 6-12m because users will want to browse further, then I would suggest that you create some subforums and shift the content there instead. This way you can index by forumid and get way faster results without losing any user experience. Anyway, if you insist on returning huge datasets back to the user, then here are more ideas: Upgrade your hardware - This is generally expensive and will only solve the problem temporarily. Implement caching - If you use 3rd party caching, I suppose it's of medium difficulty to set up. If you use MySQL's query cache, it would be pretty simple. In this example, all you'd need to do is some normalization on the linux timestamp it uses in the field list. If you round it to the nearest thousand or even hundred, it would be utilized. The way it's set up now, it can't be used. What this would do is have the query results re-used (instant repeat queries) until the data changes and invalidates it. Again, especially if you use MySQL query caching, this is a band-aid solution. Implement Sphinx -This is quite difficult / expensive to set up, but it's probably the most beneficial in terms of performance and growth support. Sphinx is a search daemon which is often used to replace keyword searching, but it can also perform full data scans VERY quickly. You can have it scan through hundreds of millions of rows in the time it would take MySQL to scan tens of thousands. For a board your size, it would be bringing the data back in under a tenth of a second easily. |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|