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 `all_friends` ADD INDEX `all_friends_idx_friend_id` (`friend_id`);
ALTER TABLE `all_friends` ADD INDEX `all_friends_idx_friend_type` (`friend_type`);
SELECT
DISTINCT all_friends.friend_id,
all_friends.hobbies AS friend_hobby
FROM
all_friends
WHERE
all_friends.friend_id NOT IN (
SELECT
DISTINCT (all_friends.friend_id)
FROM
all_friends
WHERE
(
all_friends.friend_type IN (
'Good', 'Great'
)
)
)