Your question is unclear to me. Do you say, your site is generally slow and when you create accounts and enroll to courses the above error shows up? Then they are two completely different things, for different forums.
I would start with the error. For that you need to provide full information, server platform, system software with versions, Moodle release, any non-core plug-ins installed or special configurations made, .. Then you might want to ask the moderator to move the discussion to the General help forum.
Once that is solved, if your site is still slow, you can place a detailed enquiry in this forum. For samples, go through as many other discussions as possible.