When you click a given link, it loads a page that makes a stored procedure call. If the stored procedure call takes more than a few seconds, people start clicking the link again. If they click the link a dozen times, I can see a dozen queries run on the database. The last query is the only one that returns anything to the user, but the other 11 execute to completion while using resources.
What is the best way to prevent this? Is there a way to stop it at the database level or is this an interface issue? Is this a result of how I am making my database connections with PHP?
Personally I would tackle the interface issue – the reason behind users clicking multiple times is not that the users are wrong, but rather that your site isn’t communicating anything about what it’s trying to do. Consider setting the link to disabled onclick, perhaps displaying some kind of loading animation, and then re-enabling the link once you get the callback with the data. That way the UI reflects the back-end state at all times, and also prevents users queuing up a bunch of requests!