I have a table with users with over 50000000 entries. I want to check for the presence of already registered users on the server and I execute this request.
SELECT *
FROM
(SELECT TOP (1000) *
FROM UserdatasTemp) AS ut
JOIN Userdatas AS u ON u.Login = ut.Login
AND u.Password = ut.Password
-- ...OTHER JOINS...
I use 2 unique indexes on the login and on the password column. At the same time, I have 2 query plans in which the search for the first index is slow and the second one is fast.
First plan with index IX_Userdatas_Login_Password
:
Second plan with index IX_Userdatas_Password_Login
:
I use unique indexes with login and password columns in the first index and password and login in the second. In indexes, these columns are not in the included tab.
Who can prompt why so happens and how to execute the given request more quickly?
I've tried rebuilding indexes, resizing pages, resetting stats, and rebuilding indexes again, but the problem is still there