Comment On It seems my app is running a little slow ...

Quite a few users were complaining about application performance so Keith investigated the problem. He came across this in a stored procedure that pointed him in the right direction  ... [expand full text]
« PrevPage 1Next »

re: It seems my app is running a little slow ...

2004-09-30 14:43 • by Andy
This is the best one, yet. Unbelievable!

re: It seems my app is running a little slow ...

2004-09-30 15:13 • by peter
The obvious solution is to throw more hardware at it.

re: It seems my app is running a little slow ...

2004-09-30 15:24 • by Manni
Doesn't anyone realize how efficient this is? Instead of making SQL return potential results or run through a loop, you just tell it EXACTLY what you're looking for. I suppose you could run into problems down the line if a question were to change, but what are the chances of that? People only use databases when something is set up and will never EVER change.

If you get paid per line of code, this is perfect! And what about when more questions are added? You don't want some automated system taking your job do you? This will require manual coding to account for the new question(s). This programmer deserves an award.

re: It seems my app is running a little slow ...

2004-09-30 15:27 • by rs
New Question:

How long has this person been working with SQL?

a) Less than 5 mins
b) 5 to 30 mins
c) 30+ mins

re: It seems my app is running a little slow ...

2004-09-30 15:35 • by Dave Mays
OMG. It's just wrong in so many ways I don't even know what to say.

re: It seems my app is running a little slow ...

2004-09-30 15:37 • by Brad
hahahaha

(breathe)

hahahaha

Best one in a long time.
My favorite line:

"SQL for questions 4 to 49 snipped... (Just use your imagination)"

Must have taken him years to type this all out. I'd say he must have had scripts to generate the code, but that would be giving him WAY too much credit.

And its not only this SQL, but WTF is he doing storing the full text of THE QUESTION with EVERY ANSWER!

re: It seems my app is running a little slow ...

2004-09-30 15:46 • by Joshua Bair
Hope he didn't MISSPELL anything.

That reminds me. I just saw a proposed report engine that stored the SQL statements in SQL Tables. The statements were loaded by code, then sent BACK to the server to get the actual data. The plan, apparently, was to allow the user to write his own SQL Statments to generate whatever reports he wanted.

I suggested that we just put the source code that reads the database IN the database, so that the user could modify that as well. No one laughed...

- Joshua

re: It seems my app is running a little slow ...

2004-09-30 16:17 • by Jeff S
A classic WTF, a definitely hall of famer !! I'd like to nominate this one for WTF-of-the-year so far !

re: It seems my app is running a little slow ...

2004-09-30 16:24 • by Jeff S
Actually -- does this actually execute? Is this MS SQL Server ? If so, I don't think any of those EXEC calls are legal, I believe EXEC in that format requires a stored procedure name and would set the variable being assigned to the returned value from the proc, not from a value in the recordset returned ....

re: It seems my app is running a little slow ...

2004-09-30 16:26 • by skicow
Great merciful crap. O_o

Is he actually doing anything with the totals for each question that he is querying? He/She is displaying the number of yes/no results but not the total number of results per question....Meh.

re: It seems my app is running a little slow ...

2004-09-30 16:42 • by Brendan Tompkins
Okay skicow. But calling them a he/she is a little over the top! ;)

re: It seems my app is running a little slow ...

2004-09-30 16:46 • by cm
OMG-I-LMAO

I agree with peter, a quad-processor with hyper-threading should make this run nicely ;-)

Best one yet!!

re: It seems my app is running a little slow ...

2004-09-30 17:01 • by Thomas
You can use EXEC to run a SQL string in mssql.

re: It seems my app is running a little slow ...

2004-09-30 17:25 • by Manni
I think we can forego asking whether or not the code works. In lots of code posts I've seen at least one person say "This shouldn't even run!" The code runs, or it wouldn't be used and therefore wouldn't be a WTF.

The basis of our mockery is in the fact that the code is WAY overblown and could be done with simple loops or reduced down to a query or two. Either that or as skicow pointed out, that the programmer is adding steps like getting the total number of questions via 50 separate queries and then doing nothing with the information.

re: It seems my app is running a little slow ...

2004-09-30 17:40 • by Guayo
I'm surprised he didn't named his stored proc variables like:
@iQ1_Did_any_associate_verbally_acknowledge_you_within_30_seconds_after_you_entered_the_store_Total
@iQ1_Did_any_associate_verbally_acknowledge_you_within_30_seconds_after_you_entered_the_store_Yes
and so on...

re: It seems my app is running a little slow ...

2004-09-30 17:53 • by GROUP BY
select question_text, answer_text, count(*) from tblAnswers
group by question_text, answer_text


WTF kind of a table name is "tblAnswers"?

re: It seems my app is running a little slow ...

2004-09-30 20:47 • by Jeff S
Yes, Thomas, but if you cannot use EXEC to set a variable like this code attempts to do with MSSQL, as I mention. For example, this works:

declare @Sql varchar(100);
set @SQL = 'select 1'
EXEC (@SQL)

but this does not:

declare @i int;
declare @SQL varchar(1000);
set @SQL='select 1'
exec @i = @SQL

which is what the code is attempting to do, unless I am missing something ....

(cut and paste either into Query Analyzer to see for yourself)

re: It seems my app is running a little slow ...

2004-09-30 20:48 • by Rojohn
If Dijkstra were still alive, this might inspire a new letter to the ACM: Clipboard considered harmful.

re: It seems my app is running a little slow ...

2004-10-01 07:55 • by Ray S
Hey, I wonder if the guy that put this together was also responsible for the IsValidISBN function a week or two ago?

Classic. :)

re: It seems my app is running a little slow ...

2004-10-01 08:39 • by Raymond Lewallen
Oh man, that is so freaking awesome!

re: It seems my app is running a little slow ...

2004-10-01 09:35 • by John Kerry
With my code plan I would have retrieved the records in 4 milliseconds... This coder has obviously mislead his client...

Wrong code...
Wrong place...
Wrong Time...

re: It seems my app is running a little slow ...

2004-10-01 09:41 • by TheF0o1
I have to believe that this was generated code. But then either the writer(s) of the code generator committed a WTF or it's being used as not originally intended, which is still a WTF.

The only real explanation is that "@iQ1Total" in fact describes the intelligence of the person who wrote this.

re: It seems my app is running a little slow ...

2004-10-01 10:45 • by MrWhatever
SET @strSql = "DELETE FROM [Chair]"
EXEC @strSql

re: It seems my app is running a little slow ...

2004-10-01 11:43 • by Tim Cartwright
Jeff S is right, that code will NOT run in sql server. Unless that is some other query engine that will allow that. So that is probably dead code that does not get executed, even though it is beyond atrocious.....

re: It seems my app is running a little slow ...

2004-10-01 13:05 • by Grand Diversion
Wow.

Looks like the result of a marketing person wannabe programmer trying to make themselves a survey. :P

"WTF kind of a table name is "tblAnswers"?"

I'm assuming that "tbl" is Hungarian notation for Table. This is a Table of Answers. Duh! Just so you don't get confused and think it was a view, function or even a stored procedure. LOL!!

re: It seems my app is running a little slow ...

2004-10-01 19:00 • by Jason Strate
Scary. I thought the script tables and data in our databases were pretty bad.

"WTF kind of a table name is "tblAnswers"?"

We use Hungarian notation on tables here and it drives a few people crazy but it makes sense to me. But then all database objects here have to fit a naming standard.

re: It seems my app is running a little slow ...

2004-10-02 20:30 • by ESH
I see code like this every day. I maintain it, I know the original author.

This is not, I repeat, is not an exaggeration

Re: re: It seems my app is running a little slow ...

2008-09-11 13:49 • by the amazing null (unregistered)
216973 in reply to 24314
hyperthreading + ms sql server.... ouch. more thrashing than a million megadeth concerts. i hope to never have to do that... again.
« PrevPage 1Next »

Add Comment