![]() | |
#11
| ||||
| ||||
|
|
"Captain Paralytic" <paul_lautman (AT) yahoo (DOT) com> wrote in message news:1194956220.063305.125300 (AT) d55g2000hsg (DOT) googlegroups.com... On 13 Nov, 12:07, "Roy Hann" <specia... (AT) processed (DOT) almost.meat> wrote: I also expect that most working programmers have little or no interest in SQL, regard it as a distraction, That's why there are SQL programmers! I take it you mean *expert* SQL programmers? |
|
Sure, there are such people. But I suspect there are very many more programmers writing Java and Cobol and PHP and so on, who are compelled to use SQL but regard it as something other than a core skill, and know just enough to get by. They don't want to take the time to become highly proficient with SQL. They dislike it; they probably feel it gets in the way more than it helps, and if they have to repeatedly reformulate a query looking for that one special way of expressing it so it works tolerably well, then they would (rightly) think that's just voo-doo and hate SQL even more. |
|
SQL was intended to be a goal-oriented language. The idea was (explicitly) to allow the optimizer to discern the essential meaning of the query--no matter how it was expressed--and come up with an efficient way of producing the requested result. That's how it is supposed to work, and lots of products achieve that to a remarkable degree. |
|
Flipping it around, if we had a perfect SQL engine, no one would ever ask to add a feature so they could write an equivalent query that would be slower! :-) Expert SQL programmers are actually a bad thing. We shouldn't want to want them. Roy |
#12
| |||
| |||
|
|
That is an appealing but incorrect intuition. SQL (as I wrote elsewhere) was (and is) intended to be goal-oriented. It is supposed to be declarative rather than procedural. The explicit intention was that no matter how tortured the specification of the goal is, once it is understood by the optimizer it should result in the same canonical best plan. Complete protection from the worst excesses of the willfully ignorant may not be possible, but it is already demonstrably possible to a very great degree and it is getting better all the time. Which is not to say that there aren't bad products out there. There certainly are. |
#13
| |||||
| |||||
|
|
Roy Hann wrote: "Captain Paralytic" <paul_lautman (AT) yahoo (DOT) com> wrote in message news:1194956220.063305.125300 (AT) d55g2000hsg (DOT) googlegroups.com... On 13 Nov, 12:07, "Roy Hann" <specia... (AT) processed (DOT) almost.meat> wrote: I also expect that most working programmers have little or no interest in SQL, regard it as a distraction, That's why there are SQL programmers! I take it you mean *expert* SQL programmers? I agree with Paul here. And I wouldn't say they are necessarily *expert* SQL programmers. I've seen a lot of average SQL programmers who are still good at what they do. |
|
Sure, there are such people. But I suspect there are very many more programmers writing Java and Cobol and PHP and so on, who are compelled to use SQL but regard it as something other than a core skill, and know just enough to get by. They don't want to take the time to become highly proficient with SQL. They dislike it; they probably feel it gets in the way more than it helps, and if they have to repeatedly reformulate a query looking for that one special way of expressing it so it works tolerably well, then they would (rightly) think that's just voo-doo and hate SQL even more. I don't think that's a fair statement. Most of the experienced programmers I know who use SQL treat it for what it is - just another way to access data. They may not be expert at it, but they know enough to create reasonably complex queries to get the information they want. And they know how to use EXPLAIN or its equivalent in other databases to help make their queries more efficient. |
|
SQL was intended to be a goal-oriented language. The idea was (explicitly) to allow the optimizer to discern the essential meaning of the query--no matter how it was expressed--and come up with an efficient way of producing the requested result. That's how it is supposed to work, and lots of products achieve that to a remarkable degree. No, SQL (Structured Query Language) was created to access data in IBM's System R relational database. And back in the early 70's, optimizers were a pipe dream. |
|
Current RDBMS's do try to optimize the database, and do so in different ways and to different extents. But if you know of others who do what you want, you're also free to use those products. But even the best optimizers don't get it right all of the time, and you need to have knowledge of the strengths and weaknesses of each one to be able to do it well. |
|
Flipping it around, if we had a perfect SQL engine, no one would ever ask to add a feature so they could write an equivalent query that would be slower! :-) Expert SQL programmers are actually a bad thing. We shouldn't want to want them. And if we had perfect computer systems, we would never need programmers. People would be able to just speak into a microphone and get the response to their questions. Programmers are actually a bad thing. We shouldn't want to want them. |
#14
| |||
| |||
|
|
That is an appealing but incorrect intuition. SQL (as I wrote elsewhere) was (and is) intended to be goal-oriented. It is supposed to be declarative rather than procedural. The explicit intention was that no matter how tortured the specification of the goal is, once it is understood by the optimizer it should result in the same canonical best plan. Complete protection from the worst excesses of the willfully ignorant may not be possible, but it is already demonstrably possible to a very great degree and it is getting better all the time. Which is not to say that there aren't bad products out there. There certainly are. |
#15
| |||||
| |||||
|
|
"Jerry Stuckle" <jstucklex (AT) attglobal (DOT) net> wrote in message news:nYKdnbGMULq9MKTanZ2dnUVZ_sqinZ2d (AT) comcast (DOT) com... Roy Hann wrote: "Captain Paralytic" <paul_lautman (AT) yahoo (DOT) com> wrote in message news:1194956220.063305.125300 (AT) d55g2000hsg (DOT) googlegroups.com... On 13 Nov, 12:07, "Roy Hann" <specia... (AT) processed (DOT) almost.meat> wrote: I also expect that most working programmers have little or no interest in SQL, regard it as a distraction, That's why there are SQL programmers! I take it you mean *expert* SQL programmers? I agree with Paul here. And I wouldn't say they are necessarily *expert* SQL programmers. I've seen a lot of average SQL programmers who are still good at what they do. I would hope the average SQL programmer is good at what they do! :-) But you are clearly talking about SQL programmers, not Java/Cobol/XYZ programmers who are obliged to use SQL. My claim is that those programmers should expect better. If they make the effort to write a syntactically correct statement of their required result then they ought to expect the server to figure out a good way to execute it. There is no sane argument for why they should want anything less and there are products that do much better at that than others. The ones that don't do well deserve to be criticised for it. |
|
Sure, there are such people. But I suspect there are very many more programmers writing Java and Cobol and PHP and so on, who are compelled to use SQL but regard it as something other than a core skill, and know just enough to get by. They don't want to take the time to become highly proficient with SQL. They dislike it; they probably feel it gets in the way more than it helps, and if they have to repeatedly reformulate a query looking for that one special way of expressing it so it works tolerably well, then they would (rightly) think that's just voo-doo and hate SQL even more. I don't think that's a fair statement. Most of the experienced programmers I know who use SQL treat it for what it is - just another way to access data. They may not be expert at it, but they know enough to create reasonably complex queries to get the information they want. And they know how to use EXPLAIN or its equivalent in other databases to help make their queries more efficient. There is no dispute that there are people at that level of skill, and that's great. But they are compensating for the defects of the product, and their ability to compensate makes them expert SQL programmers. But there are lots of programmers who have to use SQL who aren't at that level of skill who suffer unnecessarily. Furthermore, the ones who are at that level of skill got there through some effort that could have been devoted to something else more productive. You just can't make a case for preferring anything less than the best optimizer that the state-of-the-art can give you. |
|
SQL was intended to be a goal-oriented language. The idea was (explicitly) to allow the optimizer to discern the essential meaning of the query--no matter how it was expressed--and come up with an efficient way of producing the requested result. That's how it is supposed to work, and lots of products achieve that to a remarkable degree. No, SQL (Structured Query Language) was created to access data in IBM's System R relational database. And back in the early 70's, optimizers were a pipe dream. First of all that doesn't refute anything I said. Secondly SQL (nee SEQUEL) predates System R by many years--almost a decade. SQL was added to System R very late in the day. Thirdly there were quite reasonable RDBMS optimizers by the late 70s. And fourthly, we are in the 21st century now and what was dreamt of 30 years ago is eminently possible now--as demonstrated daily by the better products you can actually buy or download today. |
|
Current RDBMS's do try to optimize the database, and do so in different ways and to different extents. But if you know of others who do what you want, you're also free to use those products. But even the best optimizers don't get it right all of the time, and you need to have knowledge of the strengths and weaknesses of each one to be able to do it well. Sure. Experts will always be needed, but one should hope they'll be needed with ever-decreasing frequency and only for ever more complicated queries. The OP's query was, IMO, capable of a trivial optimization and there are products that you can use today that would have found it automatically. |
|
Flipping it around, if we had a perfect SQL engine, no one would ever ask to add a feature so they could write an equivalent query that would be slower! :-) Expert SQL programmers are actually a bad thing. We shouldn't want to want them. And if we had perfect computer systems, we would never need programmers. People would be able to just speak into a microphone and get the response to their questions. Programmers are actually a bad thing. We shouldn't want to want them. Maybe you think that's whimsical, but actually that is exactly what I think, in absolute, complete seriousness. Roy |
#16
| |||
| |||
|
|
"Captain Paralytic" <paul_laut... (AT) yahoo (DOT) com> wrote in message news:1194956220.063305.125300 (AT) d55g2000hsg (DOT) googlegroups.com... On 13 Nov, 12:07, "Roy Hann" <specia... (AT) processed (DOT) almost.meat> wrote: I also expect that most working programmers have little or no interest in SQL, regard it as a distraction, That's why there are SQL programmers! I take it you mean *expert* SQL programmers? Sure, there are such people. But I suspect there are very many more programmers writing Java and Cobol and PHP and so on, who are compelled to use SQL but regard it as something other than a core skill, and know just enough to get by. They don't want to take the time to become highly proficient with SQL. They dislike it; they probably feel it gets in the way more than it helps, and if they have to repeatedly reformulate a query looking for that one special way of expressing it so it works tolerably well, then they would (rightly) think that's just voo-doo and hate SQL even more. SQL was intended to be a goal-oriented language. The idea was (explicitly) to allow the optimizer to discern the essential meaning of the query--no matter how it was expressed--and come up with an efficient way of producing the requested result. That's how it is supposed to work, and lots of products achieve that to a remarkable degree. |
#17
| ||||||||||||
| ||||||||||||
|
|
Roy Hann wrote: And every database works differently. |
|
One may be the best at optimizing one SQL statement, but among the worst in optimizing a different SQL statement. No RDBMS is "best" at optimizing all SQL statements. |
|
If you're going to call yourself a programmer, it's up to you to learn the strengths and weaknesses of the RDBMS you're using, just like any other tool. |
|
There is no dispute that there are people at that level of skill, and that's great. But they are compensating for the defects of the product, and their ability to compensate makes them expert SQL programmers. But there are lots of programmers who have to use SQL who aren't at that level of skill who suffer unnecessarily. Furthermore, the ones who are at that level of skill got there through some effort that could have been devoted to something else more productive. You just can't make a case for preferring anything less than the best optimizer that the state-of-the-art can give you. No, they aren't compensating for any defects. |
|
They know EVERY tool has strengths and weaknesses. And they learn the strengths and weaknesses of the tools they use. That makes them good programmers. |
|
But if you think a RDBMS should be able to optimize everything, |
|
then why don't you write your own? |
|
I'm sure you'll do better than IBM, Microsoft, Oracle, MySQL and all the others out there. |
|
[SQL] is not a "goal-oriented language". It was never meant to be. |
|
And no, SQL does NOT predate System R. SQL was created specifically for the System R in the early 1970's by IBMers Donald D. Chamberlin and Raymond F. Boyce. Among many other such references: http://en.wikipedia.org/wiki/Sql. |
|
Sure. Experts will always be needed, but one should hope they'll be needed with ever-decreasing frequency and only for ever more complicated queries. The OP's query was, IMO, capable of a trivial optimization and there are products that you can use today that would have found it automatically. And you don't have to be an expert to learn how to write better SQL statements. Just a programmer. |
|
Programmers are actually a bad thing. We shouldn't want to want them. Maybe you think that's whimsical, but actually that is exactly what I think, in absolute, complete seriousness. And about that time mankind will be replaced by machines. |
#18
| |||
| |||
|
|
On 13 Nov, 13:34, "Roy Hann" <specia... (AT) processed (DOT) almost.meat> wrote: Actually there's another aspect that hasn't been mentioned yet and that is the database design and the choice of indexes. My background to using databases is ISAM on System 36 and CICS/VSAM. When I design database tables (structure, indexes, ...), I'm always thinking of how it will be used and what the data will look like. I know that if I design it wrong, no optimzer in the world will ever be able to access the data efficiently. It seems to me that, programmers who have no appreciation of how to craft an efficient query, are unlikely to have given sufficient thought to this important aspect. |
|
I don't see a great deal of difference between helping the optimizer by good design of database and helping it with good design of query. |
#19
| ||||||||
| ||||||||
|
|
"Jerry Stuckle" <jstucklex (AT) attglobal (DOT) net> wrote in message news:-P-dnWLLyrXfc6TanZ2dnUVZ_oGjnZ2d (AT) comcast (DOT) com... Roy Hann wrote: And every database works differently. Agreed. One may be the best at optimizing one SQL statement, but among the worst in optimizing a different SQL statement. No RDBMS is "best" at optimizing all SQL statements. Of course not, and that would be a foolish claim. I can't imagine how what I wrote could be interpreted to mean that. What I *do* claim is that some DBMSs are generally worse overall, and others are generally better overall. No one could possibly argue against that without arguing that they are all the same, and we agree they're not. It is just common sense. If you're going to call yourself a programmer, it's up to you to learn the strengths and weaknesses of the RDBMS you're using, just like any other tool. I agree. But the need to do that is not a virtue of the product. All other things being equal you should prefer the tool that puts the least burden on its user. There is no dispute that there are people at that level of skill, and that's great. But they are compensating for the defects of the product, and their ability to compensate makes them expert SQL programmers. But there are lots of programmers who have to use SQL who aren't at that level of skill who suffer unnecessarily. Furthermore, the ones who are at that level of skill got there through some effort that could have been devoted to something else more productive. You just can't make a case for preferring anything less than the best optimizer that the state-of-the-art can give you. No, they aren't compensating for any defects. Having to know a special, usually non-obvious, non-portable formulation for doing common tasks isn't a defect? |
|
They know EVERY tool has strengths and weaknesses. And they learn the strengths and weaknesses of the tools they use. That makes them good programmers. No dispute. I think programmers with those skills are admirable in every way. It's the products I'm grumbling about. But if you think a RDBMS should be able to optimize everything, Are you suggesting that isn't a desirable aspiration? Why should I want an RDBMS that doesn't if I could have one that does? |
|
then why don't you write your own? For the very simple reason that I wouldn't know how. But what I do know is how to compare existing products and rank them by how close to my ideal they get, so that I can choose the best of the many real products I can actually get/buy today. |
|
I'm sure you'll do better than IBM, Microsoft, Oracle, MySQL and all the others out there. Now, now. Be serious. |
|
[SQL] is not a "goal-oriented language". It was never meant to be. Using the term colloqually, yes it was. To quote Chamberlin and Boyce: "The work on [SQL]...is consistent with the trend to declarative problem specification." (But perhaps you have knowledge of a special domain-specific meaning of the term "goal-oriented language" that I don't share.) |
|
And no, SQL does NOT predate System R. SQL was created specifically for the System R in the early 1970's by IBMers Donald D. Chamberlin and Raymond F. Boyce. Among many other such references: http://en.wikipedia.org/wiki/Sql. SQL was the name given to the language component of System R, but it was derived from other, earlier projects at IBM and elsewhere, including a language called SQUARE. But I will concede this point. Where it came from is irrelevant to my main point that in the 21st century optimizers can reasonably be expected to be highly intelligent. |
|
Sure. Experts will always be needed, but one should hope they'll be needed with ever-decreasing frequency and only for ever more complicated queries. The OP's query was, IMO, capable of a trivial optimization and there are products that you can use today that would have found it automatically. And you don't have to be an expert to learn how to write better SQL statements. Just a programmer. What an absurd assertion. What is the difference between a programmer who writes one correct SQL statement (like the OP) and a programmer who knows how to write a better one? Isn't that the very meaning of "expert"? |
|
Programmers are actually a bad thing. We shouldn't want to want them. Maybe you think that's whimsical, but actually that is exactly what I think, in absolute, complete seriousness. And about that time mankind will be replaced by machines. For writing programs, yes. Just like we use machines for generating machine code and harvesting wheat. Roy |
#20
| |||||
| |||||
|
|
Roy Hann wrote: Having to know a special, usually non-obvious, non-portable formulation for doing common tasks isn't a defect? What is "special, usually non-obvious, non-portable"? In MySQL, you can do it all in ANSI standard SQL. Portable to every database which supports ANSI SQL. |
|
But if you think a RDBMS should be able to optimize everything, Are you suggesting that isn't a desirable aspiration? Why should I want an RDBMS that doesn't if I could have one that does? No, the impossible is not a desirable aspiration. Reality should be, though. |
|
then why don't you write your own? For the very simple reason that I wouldn't know how. But what I do know is how to compare existing products and rank them by how close to my ideal they get, so that I can choose the best of the many real products I can actually get/buy today. Then you shouldn't be complaining that programmers who DO know it well aren't getting it right. Perhaps it's a lot harder than you think - i.e. impossible - for them to get it right. |
|
SQL was the name given to the language component of System R, but it was derived from other, earlier projects at IBM and elsewhere, including a language called SQUARE. But I will concede this point. Where it came from is irrelevant to my main point that in the 21st century optimizers can reasonably be expected to be highly intelligent. Actually, not. Sure they got some ideas from SQUARE - but SEQUEL was a completely separate implementation. But if you want to say that by getting ideas from SQUARE SEQUEL was derived, then I could point out SQUARE got ideas from COBOL (which got ideas from Assembler...). |
|
Sure. Experts will always be needed, but one should hope they'll be needed with ever-decreasing frequency and only for ever more complicated queries. The OP's query was, IMO, capable of a trivial optimization and there are products that you can use today that would have found it automatically. And you don't have to be an expert to learn how to write better SQL statements. Just a programmer. What an absurd assertion. What is the difference between a programmer who writes one correct SQL statement (like the OP) and a programmer who knows how to write a better one? Isn't that the very meaning of "expert"? Not at all. Expert programmers can write much more complicated SQL statements. |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
| |