- Affected version
- 2.2.8 Patch 1
While the "Delete IP usage data after" option does help, MySQL can still pick the utterly wrong indexes which can result in very bad performance.
In the IP dialog, and the approval queue,
However the indexes for the table are;
The
In the IP dialog, and the approval queue,
\XF\Entity\User::getIp
calls XF\Repository\IP::getLoggedIp
which then triggers this query;
SQL:
SELECT ip
FROM xf_ip
WHERE content_type = 'user'
AND content_id = 'xxx'
AND action = 'register'
ORDER BY log_date DESC
LIMIT 1;
However the indexes for the table are;
PHP:
$table->addKey(['user_id', 'log_date']);
$table->addKey(['ip', 'log_date']);
$table->addKey(['content_type', 'content_id']);
$table->addKey('log_date');
The
content_type_content_id
index is good enough, but log_date
absolutely needs to be avoided as this will result in multiple full-table scan when viewing the approval queue.user_id_log_date
would need the user_id
to be sent to getLoggedIp
(or for getLoggedIp
to be smart enough to set user_id when doing content_type = 'user'
)