When a user has "I can impersonate" users selected there is one DB query for each individual Impersonation user selected. See screenshot of selected "I can impersonate" users and the corresponding amount of "SELECT * FROM [AccessUserAddress] WHERE ( [AccessUserAddress].[AccessUserAddressUserID] = @p0 AND [AccessUserAddressDefaultAddressCustomFields] = 1)" shown in the debug=true log.
We have verifed this behavior in several installations running 9.14 and above.
This gererally gives bad performance at login for users with many Impersonation relations, but it has not been problematic enough for anyone to notice it other than a slow login.
Recently one client added a lot of users/adresses in their PROD solution and now has about 20 000 adresses in the database. And some users that can impersonate about 1500 Impersonation users. In that case the login takes about 40 sec(1500/40sec = about 37 extra queries per second) and it causes severe problems in the SQL database server so that some tabels get locked. And if there is ocationally a Data import activity schduled to happen at the same time as someone logs in then the application hangs / crashes. So in this case its a very business critical problem.
The screenshot is from their STAGE solution where there are fewer users/adresses than PROD - but you see the behavior that there are 376 queries "SELECT * FROM [AccessUserAddress...." and the corresponding amout of active Impersonation users in backoffice. If the Impersonation users are deselected in the backoffice the extra 376 queries disappear from the debug=true log.
Hope you can help. Thanks
/Peter