Hello! We had an old RT 4.4.4 instance which was recently upgraded to 4.4.6 on a new OS. The SQL queries being used to do things like simple queue open-ticket listings (of the sort you get by clicking on a queue name from the stock “my queues” list on the dashboard) seem to have gotten quite a bit more complicated, and are much slower than they used to be. The backend database is MariaDB in both cases, though there was also a MariaDB upgrade inbetween. The RT config is the same between them, and we’ve long had “Set($UseSQLForACLChecks, 0);” in our local check to improve performance.
For example, in 4.4.4, the query used to show open tickets in a queue (sorted by owner) ends up:
SELECT main.*
FROM
Tickets main
JOIN Queues Queues_1 ON ( Queues_1.id = main.Queue )
LEFT JOIN Users Users_2 ON ( Users_2.id = main.Owner )
WHERE
(main.IsMerged IS NULL)
AND (main.Status != 'deleted')
AND (main.Type = 'ticket')
AND (
main.Queue = '15' AND (
(
Queues_1.Lifecycle = 'approvals' AND
( main.Status = 'new' OR main.Status = 'open' OR main.Status = 'stalled' )
) OR (
Queues_1.Lifecycle = 'default' AND
( main.Status = 'new' OR main.Status = 'open' OR main.Status = 'stalled' )
)
)
)
ORDER BY Users_2.Name ASC
LIMIT 50;
But in 4.4.6 it’s:
SELECT main.*
FROM
Tickets main
LEFT JOIN Groups Groups_2 ON ( Groups_2.Domain = 'RT::Ticket-Role' ) AND ( Groups_2.Name = 'Owner' ) AND ( Groups_2.Instance = main.id )
JOIN Queues Queues_1 ON ( Queues_1.id = main.Queue )
LEFT JOIN CachedGroupMembers CachedGroupMembers_3 ON ( CachedGroupMembers_3.Disabled = '0' ) AND ( CachedGroupMembers_3.GroupId != CachedGroupMembers_3.MemberId ) AND ( CachedGroupMembers_3.GroupId = Groups_2.id )
LEFT JOIN Groups Groups_4 ON ( Groups_4.id = CachedGroupMembers_3.MemberId )
LEFT JOIN Users Users_5 ON ( Users_5.id = CachedGroupMembers_3.MemberId )
WHERE
(Groups_4.id IS NULL)
AND (main.IsMerged IS NULL)
AND (main.Status != 'deleted')
AND (main.Type = 'ticket')
AND (
main.Queue = '15'
AND (
(
Queues_1.Lifecycle = 'default'
AND main.Status IN ('new', 'open', 'stalled')
) OR (
Queues_1.Lifecycle = 'approvals'
AND main.Status IN ('new', 'open', 'stalled')
)
)
)
GROUP BY main.id
ORDER BY MIN(Users_5.Name) ASC
LIMIT 50;
Those extra JOINs in 4.4.6 make a pretty huge difference to the query time. I’ve checked our InnoDB buffer pool and it’s got plenty of room and isn’t overloaded. Is there a way to tell 4.4.6 to not JOIN through Groups/CachedGroupMembers like that?