In case you have your own slow SQL query, you can optimize it automatically here.
For the query above, the following recommendations will be helpful as part of the SQL tuning process.
You'll find 3 sections below:
ALTER TABLE `tags_users` ADD INDEX `tags_users_idx_id` (`id`);
ALTER TABLE `tags_users` ADD INDEX `tags_users_idx_user_id_tag_id_is_self_id` (`user_id`,`tag_id`,`is_self`,`id`);
SELECT
1
FROM
tags_users
WHERE
tags_users.id IN (
SELECT
temp_dup_delete.id
FROM
(SELECT
A.id
FROM
tags_users AS A,
tags_users AS B
WHERE
A.id > B.id
AND A.user_id = B.user_id
AND A.tag_id = B.tag_id
AND A.is_self = B.is_self
GROUP BY
A.id) temp_dup_delete)