The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
||||
|
||||
Speed up my Query please
I have a quite large query to perform towards the vB database post table.
I want to pull out the last 10 posts, but I do not want to include certain threadid's and forumid's. Right now the query is like this: mysql_query("SELECT * FROM post WHERE threadid NOT IN($excludethreadid) AND forumid NOT IN($excludeforumid) LIMIT 10"); $excludethreadid is set with a bunch of threadids (into the hundreds, maybe toward a thousand). $excludeforumid has a bunch of forumids not to be included in the query result. Thing is that this query, when I have around 600+ users, is taking an extremely large amount of the CPU power and queing up requests and bogging down the whole system. Is there a better way than my version above to query the post table and exclude certain preset id's in the two fields threadid and forumid? Would appreciate help in this matter. |
#2
|
|||
|
|||
I suppose that in the real query you also have a 'ORDER BY dateline DESC'?
You could try to add indexes to both forumid & dateline to speed things up. |
#3
|
||||
|
||||
Just curious: post doesn't have a forumid column?
|
#4
|
||||
|
||||
Nope. It doesn't. Which is a royal pain in the patoot at times.
|
#5
|
||||
|
||||
Quote:
KirbyDE, yep. It is has a forumid field. Why? Quote:
But are you sure? Because this query is really annoying me to the extent that I think I'm gonna remove it. But my users really want it because it helps users not having to browse through the forum all the time. Instead just visit the first page of my site. btw, I guess you all understand that this is a vBulletin database that I am querying. The number of posts is up into the millions. |
#6
|
||||
|
||||
Normally it does not, that's why I asked.
|
#7
|
||||
|
||||
Swedie, what about caching? If it's such a large database, maybe you could create a cache for the last 10 posts. When somebody makes a new post, the cache is updated.
Amy |
#8
|
||||
|
||||
Quote:
Alright. To be sure I am quoting my own query right I'll post up the same verson i got online right now PHP Code:
I am querying the thread table. Quote:
Currently I am caching the result in a .txt file on the server. And the script only runs every 30 seconds. |
#9
|
||||
|
||||
PHP Code:
|
#10
|
||||
|
||||
Just thinking aloud... but what about putting in a dateline restriction that restricts the data to within the last week (that is assuming that you would have more than 20 within a week)?
I honestly dont know if that would help - just thinking aloud. |
Thread Tools | |
Display Modes | |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|