You can do this reasonably reliably client-side with Javascript too...
I've written the below from memory, I have used something similar in the past for exactly this situation...
<script language="javascript">
var submitCount = 0;
function doSubmit()
{
if (submitCount == 0)
{
submitCount++;
document.form1.submit();
}
else
{
alert("Please wait, lengthy query executing...");
}
}
</script>
...
<form name=...>
...
<input type="button" onClick="doSubmit();">
</form>
...
Update: andye beat me to it! This approach will only work if your clients have Javascript enabled.