This is something that is getting to be a problem on the part of the restaurants themselves. Managers encourage their servers to be extra friendly as a starting point, and think that if a server has any free time at all, it should be spent catering to the customers. Unfortunately this now ends up being "overstaying," not just the five minute water refills. A couple times I've had to use a friendly but dismissive "Thanks so much," once with an added "I'm going to get at this while it's still warm" when that wasn't enough. Other variations to the suggestions already given are "I'm going to let you get back to your work now," and "We'll give you a holler if we need anything else."
Is it my imagination, or is almost every interaction anymore, from store clerks to teachers, suppose to be "instant bffs" instead of basic, friendly courtesy??
ETA: If this is happening at a particular restaurant, it might not be a bad idea to contact them and ask them to dial back the super friendly waitstaff.