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 `UserLoginHistory` ADD INDEX `userloginhistory_idx_logdate_userid` (`LogDate`,`UserId`);
ALTER TABLE `UserLoginHistory` ADD INDEX `userloginhistory_idx_userid_logdate` (`UserId`,`LogDate`);
SELECT
ul.LogDate,
ul.UserId
FROM
UserLoginHistory ul
WHERE
NOT EXISTS (
SELECT
*
FROM
UserLoginHistory ulPrevious
WHERE
ulPrevious.LogDate < ul.LogDate
AND ul.UserId = ulPrevious.UserId
)
GROUP BY
ul.LogDate,
ul.UserId
ORDER BY
NULL