Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
slow queries on large db - 1.1.7
Hello,
The following is taken from my MySQL slow query log. MySQL is running with the default settings on its own machine. Several queries are slow, but so far this is the worst, and I decided this would be a good place to start. This query takes twenty-five seconds to execute.
# Time: 090427 12:38:30
# User@Host: vanilla
# Query_time: 25 Lock_time: 0 Rows_sent: 30 Rows_examined: 1101781
SELECT t.DiscussionID AS DiscussionID, t.FirstCommentID AS FirstCommentID, t.AuthUserID AS AuthUserID, t.WhisperUserID AS WhisperUserID, t.Active AS Active, t.Closed AS Closed, t.Sticky AS Sticky, t.Sink AS Sink, t.Name AS Name, t.DateCreated AS DateCreated, t.LastUserID AS LastUserID, t.DateLastActive AS DateLastActive, t.CountComments AS CountComments, t.CategoryID AS CategoryID, u.Name AS AuthUsername, lu.Name AS LastUsername, c.Name AS Category, b.DiscussionID is not null AS Bookmarked, utw.LastViewed AS LastViewed, coalesce(utw.CountComments, 0) AS LastViewCountComments FROM LUM_Discussion t left join LUM_User u ON t.AuthUserID = u.UserID left join LUM_User lu ON t.LastUserID = lu.UserID left join LUM_Category c ON t.CategoryID = c.CategoryID left join LUM_CategoryRoleBlock crb ON t.CategoryID = crb.CategoryID and crb.RoleID = 4 left join LUM_UserBookmark b ON t.DiscussionID = b.DiscussionID and b.UserID = 93 left join LUM_UserDiscussionWatch utw ON t.DiscussionID = utw.DiscussionID and utw.UserID = 93 left join LUM_CategoryBlock cb ON t.CategoryID = cb.CategoryID and cb.UserID = 93 WHERE (crb.Blocked = '0' or crb.Blocked = 0 or crb.Blocked is null ) AND t.Active = '1' and (cb.Blocked = '0' or cb.Blocked = 0 or cb.Blocked is null ) and (t.WhisperUserID = '0' or t.WhisperUserID = 0 or t.WhisperUserID is null ) ORDER BY t.Sticky ASC, t.DateLastActive desc LIMIT 0, 30;
SQL Beautifier + EXPLAIN: http://pastie.org/private/iczbi2zp4ai4zkvt8f4dg
You'll notice that it hits every row in LUM_Discussion. My first suspicion was that the 'ORDER BY t.Sticky ASC, t.DateLastActive desc' part of the query was slowing things down. (By default there is an index on LUM_Discussion.DateLastActive.) There is no index on LUM_Discussion.Sticky. Adding an index to Sticky did not work. Nor did removing the DateLastActive index and adding a multi-column index on (Sticky, DateLastActive). So it appears the problem is not there. The EXPLAIN command seems to confirm this.
How can we speed this up?
0
Comments