Word of the Day: Query Anxiety

This post is more than 2 years old.

Word: Query Anxiety

Definition: The feeling you get in your gut when you are running a query and also dumping it and you realize you screwed up the SQL and your about to get about 10000 records displayed on screen.

Not that I've ever done that. Really. Pardon me while I shut down/restart Firefox and get back a few gigs of RAM.

Raymond Camden's Picture

About Raymond Camden

Raymond is a senior developer evangelist for Adobe. He focuses on document services, JavaScript, and enterprise cat demos. If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support. You can even buy me a coffee!

Lafayette, LA https://www.raymondcamden.com

Archived Comments

Comment 1 by Chad posted on 2/1/2008 at 9:12 PM

Or when you are developing code that uses a SQL delete and you run the page and it takes WAY longer then it should. Then you really wish you had setup a development SQL server intead of testing the code on the production database.

Comment 2 by Ben Nadel posted on 2/1/2008 at 9:13 PM

Rule #1 for dumping queries with debugging purposes... use TOP attribute.

I learned this lesson when debugging reports :)

Comment 3 by Hakki posted on 2/1/2008 at 9:23 PM

So what.. It is your development server and you are the ONLY one on it!

Comment 4 by joel posted on 2/1/2008 at 9:25 PM

Ah, the old Cartesian product. Don't you just love it?

Comment 5 by Tom K posted on 2/1/2008 at 9:48 PM

Or when you forget the WHERE clause in DELETE * from....

Comment 6 by Akira posted on 2/1/2008 at 9:48 PM

I usually try to run the queries in a query analyzer before running them in CF... isql has a stop button that comes in rather handy sometimes. :)

Comment 7 by luke posted on 2/2/2008 at 12:54 AM

updating an advertiser's phone number without the 'where' clause on a very popular classified site... thats one hot number for the evening...

Comment 8 by robert posted on 2/2/2008 at 1:19 AM

my favorite SQL tip for testing queries is to surround all SQL within a transaction in query analyzer.
EX:

BEGIN TRAN

DELETE....

SELECT.... (this to see that my previous delete did what I thought it should)

ROLLBACK TRAN

Once I am happy with the results I can just change the ROLLBACK TRAN to a COMMIT TRAN.

Comment 9 by Scott Bennett posted on 2/2/2008 at 2:06 AM

@Tom K,

LOL! yeah that happened to me once on a production system when I was an inexperienced programmer... I Deleted all the orders from the system... then scrambled for the half hour restoring the database (fortunately I had a good back up plan in place and we only lost a few minutes worth of orders). There's a lesson you only want to learn once. Now I always verify any manually written delete statements with a select statement first, then change the "select *" to "Delete" once I'm satisfied I am deleting the right records. Even still I usually feel some "query anxiety" where I flash backs of my 1 and only mistake in that area, and knock on the wood of my desk before I click "execute" =)

Comment 10 by shag posted on 2/2/2008 at 3:26 AM

i once ran a delete on a really big (data warehouse) table. after a few minutes i thought something was up. then i realized the where clause was incorrect. hit stop and waited for a few more minutes... fortunately the conditions were so off it was only doing a table scan, but nothing got deleted.

Comment 11 by Camilo posted on 2/5/2008 at 9:49 PM

Or when you are developing code that uses a SQL , and testing a mail form, and you have 100000 emails in your box!

Comment 12 by Dumberer posted on 2/6/2008 at 12:33 AM

Back in CF4 days, I did this:

select email from users, agencies

cfmail to:#email# ......

ouch. >50K emails. my bad!

Fortunately I made a SECOND error and accidentally sent all of them to myself....

yeah.