go on beat me, I know you're doing wrong, but just beat me because its my fault and I'm not going to stop you
Well you might think that my blog has been hijacked but
it hasn't.
This is a statement I put into some feedback to the product team about SQL
Server's attitude to bad plans.
If you have a bad query plan in your cache that isn't suited to all the
parameter distributions you are using it with your SQL Server is effectively
saying "go on beat me, I know you're doing wrong, but just beat me because I'm
not going to stop you".
I'm talking about queries that normally process a few hundred pages but
when executed with the wrong parameters end up processing 100s of thousands of
pages. The worst I saw was a bad plan with full text that had a figure in excess
of 1000 million pages being read for one query. This is the classic case of a
query plan gone bad.
Why oh why can't SQL Server do anything about it, they know the estimated
numbers and the actual numbers because they give then to you in the execution
plan, so why not use them to detect a bad plan, and then bar it from the
server.
Why can't SQL Server be a bit stricter and give the plan the boot rather than
being a masochist
"1. gratification gained from pain, deprivation, degradation, etc.,
inflicted or imposed on oneself, either as a result of one's own actions or the
actions of others
2. the act of turning one's destructive tendencies inward or upon
oneself."