I know how swapping basically works, why it's automatic and why it's generally a good thing.
There is, however, a common scenario where I wish I had more control.
I write LOB web applications with IIS and Sql Server (this question is more general than that though).
Those applications are hosted on dedicated servers (or virtual machines on those) and used infrequently. It can happen that they aren't used for hours. When the next user then makes a request, the first database request to SqlServer usually takes at least a couple of seconds. And that's not even counting other components of the stack that need to wake up as well.
I would think this is at least in part due to IO that really should have been avoided since it had that information in memory once. (The queries had been run before at some point in the past.)
The machine also runs a virus scanner (company policy), and my guess is that after a sweep of that all other processes are entirely swapped out. And besides virus scanners, there are sometimes other maintenance processes that over time can temporarily consume memory.
I wouldn't even mind the application stack to be put to sleep temporarily, as long as it's put back in memory when the machine becomes idle again - but I don't think this is how it works.
This sounds like a very general problem that basically all people have who deploy applications with a more infrequent usage. It also applies to all operating systems, web servers and databases.
Of course I know I could make regular dummy requests that keep the server busy - and in fact I'm already doing that to keep the non-database part of the stack.
What else can be done here? Especially, what can be done economically and practically?