- Feature Articles
- CodeSOD
-
Error'd
- Most Recent Articles
- Stop Poking Me!
- Operation Erred Successfully
- A Dark Turn
- Nothing Doing
- Home By Another Way
- Coast Star
- Forsooth
- Epic
- 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
Rather than a "Wooden Table", this photograph was taken on a WHITEBOARD.
Admin
...
That's insane.
captcha: populus - boring game
Admin
Probably true.
Admin
Fr1st two words: SELECT ( SELECT. That's already very promising.
Also, not fr1st!
Admin
Holy Fuck, no human could write that!
Admin
I don't get it. So much crap posted on The Daily WTF is for initiates only with no explanations for those of us with over 20 years programming experience who lack that finite bit of knowledge that makes YOUR WTF understandable.
Admin
Admin
Looking at that image gave me a similar feeling to watching VanDamme dancing in the movie Kickboxer.
Admin
I've already seen a ten-page-long query. And it was used in a real application. Thankfully, I've never had to debug it.
Admin
Why not tidysql the query instead of printing it out unreadable? (or printing it out at all)
Admin
Admin
I've seen many things do this. Use a beautifier. Sure it'll use more paper, but stable it together and it's worth it.
Admin
Admin
I feel for the his colleague.
Admin
The problem is on page 4, line 27. Isn't that obvious to everyone?
Admin
The worst part is I looked at that query and was like, oh hibernate probably generated that query. Then I looked again and from what I can see it doesn't look like it's aliasing tables/fields the way that hibernate would. This leads me to believe that someone probably wrote this...
Admin
Admin
Seen a query of this size that was generated by an alien logic that my colleague wrote... and strangely enough, it was the only possible way to get the desired result as the DB structure was just as alien.
Admin
I'm feeling like I know more about frits than I want to know right now.
I'm off to have a shower.
Admin
Admin
Admin
Admin
Admin
I've got one. Try being told to pull out info from 245 tables that all need to be related. To create another unassociated, mess of a db with..... :( Although my is spaced a lot better :)
Admin
Admin
Then again, at least I've been warned now.
Admin
Awesome.. the mail reads "The platform is very slow and produces a lot of errors. Could you check this?"
Admin
If this is Orcle, Tomas Kyte can certenly help with it.
Admin
I'd bet on generating reports that require aggregate functions while not actually using any aggregate functions.
My own record in reporting is a page and a half on one SQL-query (unbeautified). 7K of text, optimized the heck out of, to run in under two seconds every few hours.
Admin
Oh my god... it's full of stars.
Admin
Admin
http://tinyurl.com/QueryOfDespairReaction
That's the first thing that sprung to mind when I saw that printout.
Also, they need a highlighter to make it have some more colour to discern various bits of it.
Admin
Admin
I wound up writing a hideous abomination of an 8+-way union, once. IIRC, it was a bunch of reporting queries that needed to be squished together, so the individual queries weren't terrible, there were just a lot of them.
It's also possible that it's a bunch of MS Access queries that have been strung together, which might explain the SELECT (SELECT thing at the start. Access has traditionally had some curiously quaint restrictions on query size that tends to turn any even moderately complex query into a maze of small, twisty queries, all alike.
Finally, it could just be that whoever created that thing had no idea what they were up to.
Admin
Selffix: aggregate functions = somewhat complex aggregate functions, like AVG .. OVER ... RANGE BETWEEN .. etc.
Admin
Admin
There is no hope. The best you can do is put the beast down. Burn the document, wipe the drives, torch the building... Oh, and flush the site with holy water just to be on the safe side.
Admin
No. Please, just - no. horrified
Admin
That's pretty bad, but in my experience such queries are usually a result of
This massive beast is most likely a handful of copies of several smaller-but-ever-so-slightly-different beasts all JOINed and UNIONed together. Example:
I bet if you format it, it'd take (at most) only a couple months and all your remaining sanity to refactor it into something mentally-parsable.
Admin
Admin
Am I the only one here that wishes he (or she) could attempt to clean that up and then refactor it? :D
Inside that ugly mess is some beautiful code, just trying to come out.
Admin
Nuke the site from orbit. It's the only way to be sure.
Admin
But, yeah. When I was decoding Access queries, many oaths were sworn and curses invoked.
Admin
Just out of sheer curiosity, I really wish to see this query in full.
Admin
Obligatory grammar snark:
"I don't think anyone can help me," the his colleague wrote.
CHOOSE ONE OR THE OTHER ALEX.
Admin
As a wise man once said, "Just remember: what has been seen, cannot be unseen."
Admin
On the plus side (for Jeroen's colleague), since this SQL was submitted as a CodeSOD instead of a Representative Line, I assume it implies some semblance of sanity in the rest of the source.
Admin
There's only one Alex writing this, grammar boy.
(I gots to keep up my grammar Nazi rep, yo)
Admin
I once helped out on a project with a SQL query that long that took 70 seconds to complete on average (not good for a web app!). I fixed it by extracting the relevant data from the database and doing the search in RAM, reducing the query time to sub second. Some things are best not done with a relational database.
Admin