The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
||||
|
||||
slow query for thread.forumid. help me optimize
This query is slow (0.15 seconds) despite of having indexes everywhere.
Code:
SELECT SQL_NO_CACHE post.postid FROM post INNER JOIN thread ON(thread.threadid=post.threadid) INNER JOIN attachment ON (post.postid = attachment.contentid) WHERE thread.forumid = 1 Code:
SELECT SQL_NO_CACHE post.postid FROM post INNER JOIN thread ON(thread.threadid=post.threadid) INNER JOIN attachment ON (post.postid = attachment.contentid) Code:
SELECT SQL_NO_CACHE post.postid FROM post INNER JOIN thread ON(thread.threadid=post.threadid) WHERE thread.forumid = 1 Found the solution. This is extremely fast. The forumid restriction in the inner join thread seems to be very good. Code:
SELECT SQL_NO_CACHE post.postid FROM post INNER JOIN (SELECT threadid FROM thread WHERE forumid=1) AS thread ON(thread.threadid=post.threadid) INNER JOIN attachment ON (post.postid = attachment.contentid) |
Благодарность от: | ||
al3bed |
#2
|
|||
|
|||
Glad you found the solution. Before you were selecting all threads and then applying the forumid restriction!
Happy coding. p.s. you don't need those parenthesis for the on clause, in case you didn't know. |
Thread Tools | |
Display Modes | |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|