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 - Simon Sabin UK SQL Consultant's Blog

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."


Published 11 December 2009 22:28 by simonsabin
Filed under:

Comments

# Twitter Trackbacks for 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 [sqlblogcasts.com] on Topsy.com

Pingback from  Twitter Trackbacks for                 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         [sqlblogcasts.com]        on Topsy.com

12 December 2009 09:31 by SqlServerKudos

# 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

Kudos for a great Sql Server article - Trackback from SqlServerKudos

22 December 2009 23:15 by TheSQLGuru

# re: 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

I would definitely like to see a report that gives you plans with excessive estimated/actual skew.  I would also like the ability to manually flush an individual plan from the cache.  Your idea to have it automatically done definitely has merit.