- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
Admin
Admin
EDIT: oops, boog beat me to it... DAMN YOU BOOG!!!
Admin
Admin
I wish I had a dime for each time I had that experience
Admin
As the BASIC interpreter would say: ?REDO FROM START
Admin
They must be using Magento...
Admin
Admin
Looks like a great query for EXPLAIN. What kind of database is configured with a statementbuffer this big?
Admin
Presented to you by the movement, "Occupy Query Engine."
Admin
This query is bigger than my mother-in-law...
Admin
You've been in programming 20 years and don't know what a query is?
I think I smell some BS, but just in case I'm wrong about that, here goes: It's ONE friggin' SQL statement that's MANY pages long.
Admin
Yes. The only way it could possibly be worse is if they used column and table names that were keywords:
SELECT SELECT, INTO, FROM, ON FROM JOIN JOIN INTO ON SELECT = INTO AND ON = UNION
(DB2 SQL has no reserved words; given the right table definitions, the above is legal!)
Admin
Admin
I read "Magneto" at first, and I thought, yeah, he's the one who erases disks, isn't he? PERfect.
Admin
Is there anything you could do other than just rewriting the damn thing?
Admin
Pleasant little exercise. Great fun. On a par with replacing a DB table full of hardwired SQL statements, very similar but with subtle differences, with a stored procedure that built the SQL dynamically. Utterly unmaintainably impossible to read, but saved an entire table.
Admin
Find the guy who wrote it and keelhaul him?
Admin
FTTFY
captach: iusto... iusto care about efficiency, but now that nobody else does, why should I?
Admin
We all know the reason why. Because someone wrote a huge query for some "complex" task and it became taboo to fix as the years went on out of fear of breaking something if someone decided to refactor it and pare it down.
Admin
I doubt a human wrote this SQL. It looks like a program-generated query. I could list some programs at our company that make such crappy SQL.
We have a vendor whose software creates just that kind of SQL query. It has that "SELECT (SELECT COUNT(*)...)," sub-query in the SELECT-list pattern. It writes multiple JOINs to the same table to get (key, value) pairs.
We hired an Oracle consultant firm to tune that vendor's SQL. Their response was a firm "Re-write all the queries."
Admin
Take off and nuke the site from orbit; it's the only way to be sure.
Admin
My Stars.... Its full of Gods!!!
Admin
Admin
Came across a query like that once when asked to track down a bug in a report.
Spent a couple of hours reading through it before locating a comment with the Lead Dev's name on it - he was in the office the next day so I asked for his help on it.
"Oh don't try and debug THAT" he said. "I just sat down one night and dumped my brain out in one big splat of SQL - will probably have to do it all again to fix this issue".
Admin
Admin
That's no query. It's a space station.
Admin
Curses! Yet another failed attempt to summon the almighty Cthulhu.
Admin
Ahh, so this is what happens when you use LINQ to SQL.
Admin
Admin
Meh .. why do people even try to debug that kind of crap .. you take the output, reproduce it with "saner" SQL and be done with it, it'll always be shorter and less of a mental health hazard than trying to deal with the squidmonster ...
Admin
Obviously, the solution is removing the query and starting again.
It's just one query.
Admin
Admin
Let Alex have a the life, we humans can parse it.
Admin
Just one query? This thing has more selects than i care to count.
This might even reach a kind of perverse nirvana where it doesn't deviate at all from the median frequency of SQL keywords used in an average project for selects. All joined together.
Admin
In your over 20 years of programming experience, have you really never watched a new programmer clumsily "write" their first big SQL query?
Admin
Admin
Ironically, YAGNI.
Admin
As a sociopath, I would like to imagine that this query returns a result set of two columns: the first column contains a unique id number and the second column contains some CSV or XML. The query collects all possible data you could be looking for in all possible forms you could want it. Any time one wants to look up anything in the database, just run this single query and get the row with the id number of the information you want. It will be right there, in easy-to-read CSV/XML form.
No more error-prone writing of multiple queries! Just one, solid query that will receive rigorous testing as everything depends on it! Brillant!
Admin
All you need are my butt cheeks to crack this nut.
Admin
Admin
Seriously? You can't figure out why an SQL query that is 6 full pages when printed would be a problem?
Admin
Why are the worst WTFs on this site always in Dutch...
Admin
I doubt it.
Captcha "inhibeo" I inhibeo you from writing crap like that.
Admin
Admin
Admin
none of you peepul have working experence with Kristal reports. That's one softwear that will write complex querees and mess with your mind all time.
Admin
Admin
Admin
My only hope is that a program generated most of this query and not an actual person. I would laugh if the error is because the query is so long that the program running it is truncating part of the query off, and it just happens to truncate in such a way that the query can still be run.
On a side note I do not think I could even test or try debugging the sql query by running it from a cmd line without it running out of buffer.