News for hackers. Stuff that matters.
Re:Results of the SQL Performance Quiz by bradleyjg on Thursday February 20, 2014 @10:51AM (#7271375)
The fact that something like this is necessary just goes to show you how much of a failure SQL is compared to what it was supposed to be.

Remember the promise of a "declarative language" where you just had to tell it what you want, and it took care of the details?

Re:Results of the SQL Performance Quiz by jcampbell1 on Thursday February 20, 2014 @11:48AM (#7271802)
I reach the opposite conclusion. These are premature optimization tweaks which means tons of people are using SQL successfully without knowing them.

You could argue CSS is a failure, because designers don't know that

    #sidebar .widget
is slower than

    .widget
I'd argue that it is evidence CSS is a success because it makes no real difference, and people opt for the more readable solution.
Re:Results of the SQL Performance Quiz by bduerst on Thursday February 20, 2014 @01:58PM (#7272814)
I tried to think of an analogy of someone dragging CSS into this conversation, but I couldn't. Maybe like throwing a dead cat into a room full of aristocrats?
Re:Results of the SQL Performance Quiz by rschmitty on Thursday February 20, 2014 @10:31PM (#7275296)
You said cats and aristocrats and all I could think of was the movie The Aristocats.. so to me they seemed related :x
Re:Results of the SQL Performance Quiz by taeric on Thursday February 20, 2014 @12:41PM (#7272266)
Do you have a good link for numbers on this css point? I would expect speed differences, but my naive view would be that they wouldn't be much.
Re:Results of the SQL Performance Quiz by jcampbell1 on Thursday February 20, 2014 @01:15PM (#7272530)
The difference is probably .1us. You may find it interesting why browsers match CSS selectors from right to left (though this is a useless bit of trivia). see:

http://stackoverflow.com/questions/5797014/why-do-browsers-m...

Re:Results of the SQL Performance Quiz by rimantas on Thursday February 20, 2014 @12:53PM (#7272364)
The difference is not worth talking about at all.
Re:Results of the SQL Performance Quiz by nousernamesleft on Thursday February 20, 2014 @03:02PM (#7273177)
>These are premature optimization tweaks

How can you apply a blanket "premature" to this? The questions are simply "can this be improved?". There's nothing premature about it, it is a quiz.

Re:Results of the SQL Performance Quiz by jcampbell1 on Thursday February 20, 2014 @03:52PM (#7273476)
It is a reference to this well known quote:

"Programmers waste enormous amounts of time thinking about, or worrying about, the speed of noncritical parts of their programs, and these attempts at efficiency actually have a strong negative impact when debugging and maintenance are considered. We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil. Yet we should not pass up our opportunities in that critical 3%." --Donald Knuth

Re:Results of the SQL Performance Quiz by skyebook on Thursday February 20, 2014 @06:52PM (#7274507)
Except using indexes is a major part of developing for a database. In many simple schemas, performance will completely break down without proper indexing. That's a bit different than spending time investigating if for-each is faster than a traditional loop.
Re:Results of the SQL Performance Quiz by jcampbell1 on Thursday February 20, 2014 @10:55PM (#7275357)
> Except

I am not sure what the exception is about. I agree 100% with the rest of your comment.

Re:Results of the SQL Performance Quiz by skyebook on Thursday February 20, 2014 @11:33PM (#7275466)
My exception was to the idea of this being a premature optimization (sorry, I probably should've replied directly to your comment with the CSS example)
Re:Results of the SQL Performance Quiz by nousernamesleft on Thursday February 20, 2014 @04:19PM (#7273682)
I am aware of that quote. And that is precisely my point, he is talking about premature optimization, not optimization. What could possibly make you think that the questions in this quiz are examples of premature optimization?
Re:Results of the SQL Performance Quiz by sokoloff on Thursday February 20, 2014 @11:18AM (#7271576)
SQL is a reasonably declarative language in that it will give you the correct answer without you knowing all the gory internal details.

This quiz is about performance tuning, not correctness. For plenty of valuable real-people use cases, it's plenty fast without any performance tuning.

Re:Results of the SQL Performance Quiz by Guvante on Thursday February 20, 2014 @11:39AM (#7271727)
As much as we would love to have a magical language that knows exactly how to take anything and make it performant enough, there is a decent amount of evidence to say that is impossible.

Honestly though the nice thing about SQL is you can quickly get something that works, and then use tracing tools to figure out what is taking longer than it should.

Re:Results of the SQL Performance Quiz by Spooky23 on Thursday February 20, 2014 @12:44PM (#7272295)
Promise delivered.

Think of the first question. If you're going to use a function to transform data, you're going to take a performance hit vs. just doing and indexable operation against the data.

If you want a facility that will magically figure out what you want when you are unable to express what you want, good luck. That's unicorn territory.

Re:Results of the SQL Performance Quiz by thwarted on Friday February 21, 2014 @02:38AM (#7275838)
Reminds me of this Babbage quote:

"On two occasions I have been asked, 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question." ~ Charles Babbage

Re:Results of the SQL Performance Quiz by fleitz on Thursday February 20, 2014 @05:27PM (#7274128)
SQL is a query language and an RDBMS is an implementation.

It's like calculus, you can compute efficiently or inefficiently it has nothing to do with calculus.

The same developers that make retarded SQL queries make god awfully slow programs with their pointer chasing mess because they don't understand that their programs run on actual real hardware and that a cache miss is pretty much the single most expensive operation a modern CPU can make by 2 to 3 orders of magnitude.

They just go on and on about interfaces, inline methods, virtual methods, etc, and never check whether their fancy smancy object fits on a cache line. Its the same with databases they just talk about 'webscale' and 'big data' abandon SQL and then wonder why their DB explodes once it reaches 100 GB.

Re:Results of the SQL Performance Quiz by cleaver on Thursday February 20, 2014 @09:18PM (#7275052)
SQL is a bit deceptive in that it cloaks set-based operations in something apparently simple. Iterative operations are easier for most people to conceptualize—you could create a flow chart, whereas sets require a bit of math. Once you can think in terms of sets, SQL becomes a lot clearer. The issue with sets is, in my opinion, the root of problems in Object-Relational Mapping.

There were other query languages that were less of a messy compromise. QUEL, for example was based more rigorously on relational calculus. I think it never took off because the dumbed-down SQL was a little easier for programmers to conceptualize initially.

Re:Results of the SQL Performance Quiz by eru on Friday February 21, 2014 @01:07AM (#7275671)
Actually SQL gives you bag semantics, not set semantics. (But otherwise, yes.)