Since we are using VB 4.1.9 (after upgrading from VB 3.6.x) we are experiencing locking problems on our forums which seems to be caused by an attachment related query running for 280+ seconds each time it is called. This results in our users being hanged up for minutes several times each hour. The query consists of three sub-queries united into one.
The middle query seems to be the pitfall taking 98% of the processing time (determined by splitting up the query and running them independently). This part seems to collect attachment information from the, by the user accessible visible forums posts (via the visible threads) which are not under moderation and have a contentid = 0 and a contenttypeid = 1. The generated query seems to be very efficient put together (with a lots of OR's filtering the same sub-set of forums).
Questions:
1) which action is causing these types of queries to be generated (I can't find it in any php file because it seems to be dynamically build up)?
2) is there a solution to resolve this lengthy run-time (converting tables to InnoDB, adding indexes, applying a VB patch, others???)
Troublesome query:
(SELECT a.attachmentid, a.contenttypeid, a.displayorder, a.counter
FROM vBattachment AS a
INNER JOIN vBfiledata AS fd ON ( a.filedataid = fd.filedataid )
LEFT JOIN vBattachmenttype AS at ON ( at.extension = fd.extension )
INNER JOIN vBalbum AS album ON ( album.albumid = a.contentid )
LEFT JOIN vBprofileblockprivacy AS pbp ON ( pbp.userid = a.userid
AND pbp.blockid = 'albums' )
LEFT JOIN vBuser AS user ON ( a.userid = user.userid )
WHERE a.contenttypeid =8
AND (
(
a.contentid =0
AND a.userid =33
)
OR (
a.contentid <>0
)
)
AND a.contentid <>0
)
UNION ALL (
SELECT a.attachmentid, a.contenttypeid, a.displayorder, a.counter
FROM vBattachment AS a
INNER JOIN vBfiledata AS fd ON ( a.filedataid = fd.filedataid )
LEFT JOIN vBattachmenttype AS at ON ( at.extension = fd.extension )
LEFT JOIN vBpost AS post ON ( post.postid = a.contentid )
LEFT JOIN vBthread AS thread ON ( post.threadid = thread.threadid )
LEFT JOIN vBuser AS user ON ( a.userid = user.userid )
WHERE a.contenttypeid =1
AND (
(
a.contentid =0
AND a.userid =33
)
OR (
thread.forumid
IN ( 0, 1, 64, 65, 11, 9, 10, 14, 13, 75, 62, 63, 44, 71, 72, 73, 74 )
AND (
thread.forumid
IN ( 0, 1, 64, 65, 11, 9, 10, 14, 13, 75, 62, 63, 44, 71, 72, 73, 74 )
OR thread.postuserid =33
)
AND (
a.state <> 'moderation'
OR a.userid =33
OR thread.forumid
IN ( 0, 1, 64, 65, 11, 9, 10, 14, 13, 75, 62, 63, 44, 71, 72, 73, 74 )
)
AND (
(
post.visible =1
AND thread.visible =1
)
OR (
thread.forumid
IN ( 0, 1, 64, 65, 11, 9, 10, 14, 13, 75, 62, 63, 44, 71, 72, 73, 74 )
)
OR (
thread.forumid
IN ( 0, 1, 64, 65, 11, 9, 10, 14, 13, 75, 62, 63, 44, 71, 72, 73, 74 )
AND post.visible =2
AND thread.visible =2
)
)
)
)
AND a.contentid <>0
)
UNION ALL (
SELECT a.attachmentid, a.contenttypeid, a.displayorder, a.counter
FROM vBattachment AS a
INNER JOIN vBfiledata AS fd ON ( a.filedataid = fd.filedataid )
LEFT JOIN vBattachmenttype AS at ON ( at.extension = fd.extension )
INNER JOIN vBsocialgroupmember AS sgm ON ( sgm.userid = a.userid
AND sgm.groupid = a.contentid
AND sgm.type = 'member' )
INNER JOIN vBsocialgroup AS sg ON ( sg.groupid = a.contentid )
LEFT JOIN vBuser AS user ON ( a.userid = user.userid )
WHERE a.contenttypeid =7
AND (
(
a.contentid =0
AND a.userid =33
)
OR (
sg.options &8
)
)
AND a.contentid <>0
)
ORDER BY counter DESC
LIMIT 0 , 5
The middle query seems to be the pitfall taking 98% of the processing time (determined by splitting up the query and running them independently). This part seems to collect attachment information from the, by the user accessible visible forums posts (via the visible threads) which are not under moderation and have a contentid = 0 and a contenttypeid = 1. The generated query seems to be very efficient put together (with a lots of OR's filtering the same sub-set of forums).
Questions:
1) which action is causing these types of queries to be generated (I can't find it in any php file because it seems to be dynamically build up)?
2) is there a solution to resolve this lengthy run-time (converting tables to InnoDB, adding indexes, applying a VB patch, others???)
Troublesome query:
(SELECT a.attachmentid, a.contenttypeid, a.displayorder, a.counter
FROM vBattachment AS a
INNER JOIN vBfiledata AS fd ON ( a.filedataid = fd.filedataid )
LEFT JOIN vBattachmenttype AS at ON ( at.extension = fd.extension )
INNER JOIN vBalbum AS album ON ( album.albumid = a.contentid )
LEFT JOIN vBprofileblockprivacy AS pbp ON ( pbp.userid = a.userid
AND pbp.blockid = 'albums' )
LEFT JOIN vBuser AS user ON ( a.userid = user.userid )
WHERE a.contenttypeid =8
AND (
(
a.contentid =0
AND a.userid =33
)
OR (
a.contentid <>0
)
)
AND a.contentid <>0
)
UNION ALL (
SELECT a.attachmentid, a.contenttypeid, a.displayorder, a.counter
FROM vBattachment AS a
INNER JOIN vBfiledata AS fd ON ( a.filedataid = fd.filedataid )
LEFT JOIN vBattachmenttype AS at ON ( at.extension = fd.extension )
LEFT JOIN vBpost AS post ON ( post.postid = a.contentid )
LEFT JOIN vBthread AS thread ON ( post.threadid = thread.threadid )
LEFT JOIN vBuser AS user ON ( a.userid = user.userid )
WHERE a.contenttypeid =1
AND (
(
a.contentid =0
AND a.userid =33
)
OR (
thread.forumid
IN ( 0, 1, 64, 65, 11, 9, 10, 14, 13, 75, 62, 63, 44, 71, 72, 73, 74 )
AND (
thread.forumid
IN ( 0, 1, 64, 65, 11, 9, 10, 14, 13, 75, 62, 63, 44, 71, 72, 73, 74 )
OR thread.postuserid =33
)
AND (
a.state <> 'moderation'
OR a.userid =33
OR thread.forumid
IN ( 0, 1, 64, 65, 11, 9, 10, 14, 13, 75, 62, 63, 44, 71, 72, 73, 74 )
)
AND (
(
post.visible =1
AND thread.visible =1
)
OR (
thread.forumid
IN ( 0, 1, 64, 65, 11, 9, 10, 14, 13, 75, 62, 63, 44, 71, 72, 73, 74 )
)
OR (
thread.forumid
IN ( 0, 1, 64, 65, 11, 9, 10, 14, 13, 75, 62, 63, 44, 71, 72, 73, 74 )
AND post.visible =2
AND thread.visible =2
)
)
)
)
AND a.contentid <>0
)
UNION ALL (
SELECT a.attachmentid, a.contenttypeid, a.displayorder, a.counter
FROM vBattachment AS a
INNER JOIN vBfiledata AS fd ON ( a.filedataid = fd.filedataid )
LEFT JOIN vBattachmenttype AS at ON ( at.extension = fd.extension )
INNER JOIN vBsocialgroupmember AS sgm ON ( sgm.userid = a.userid
AND sgm.groupid = a.contentid
AND sgm.type = 'member' )
INNER JOIN vBsocialgroup AS sg ON ( sg.groupid = a.contentid )
LEFT JOIN vBuser AS user ON ( a.userid = user.userid )
WHERE a.contenttypeid =7
AND (
(
a.contentid =0
AND a.userid =33
)
OR (
sg.options &8
)
)
AND a.contentid <>0
)
ORDER BY counter DESC
LIMIT 0 , 5
Comment