![]() | |
![]() |
| | Thread Tools | Display Modes |
#21
| |||
| |||
|
|
(drawnai (AT) hotmail (DOT) com) writes: Defined behaviour is as defined behaviour does. Outperforming an equivalent query ten to one is worth a rewrite 5 years from now, in the unlikely event that microsoft, remove the ability. But the ability isn't there. It only looks like it is. That's why it's undefined. In SQL Server 6.5 GROUP BY implied an ORDER BY. Not so any more. In SQL 2000 people would put TOP 100 PERCENT ORDER BY in a view, and they found that they did seem to need an ORDER BY when selecting from the view. In SQL 2005 more than one have found that they don't get away with it. You get the result you get by happenstance. There is nothing that Microsoft can remove, because they never added it. One day the optimizer decides to do a different plan, and you don't get the result you wanted. Of course, you may be prepared to take the gamble, but the day it breaks, it's going to break hard. |
|
From .net 1.1, to .net 2.0 invoking the Sleep method, meant a change from a class member, to a static member, meaning only a thread can |
| -- Erland Sommarskog, SQL Server MVP, esquel (AT) sommarskog (DOT) se Books Online for SQL Server 2005 at http://www.microsoft.com/technet/pro...ads/books.mspx Books Online for SQL Server 2000 at http://www.microsoft.com/sql/prodinf...ons/books.mspx |
#22
| |||||
| |||||
|
|
drawnai (AT) hotmail (DOT) com wrote: David Portas wrote: drawnai (AT) hotmail (DOT) com wrote: As for your comments about updates that affect multiple rows being undefined, I'm afraid you're wrong. Update table set @fred = column = @fred + 1 is defined in SQL server's own help, please look it up if you don't believe me. There is a difference between valid syntax and defined behaviour. BOL Defined behaviour is as defined behaviour does. Outperforming an equivalent query ten to one is worth a rewrite 5 years from now, in the unlikely event that microsoft, remove the ability. (This goes against all precedents as MS have done very little but improve ability rather than remove it.) I understand your purist position though, I used to be a software engineering purist, but after 30 years of writing code, I now hold the cost benefit analysis position. If I can generate, orders, multidimensional rolling averages, and all kinds of crap with a single pass of a table, rather than generating a gig of transaction log, and 5 Gig of tempdb allocation, then I do it. Similarly, if I can implement the kind of parametric query, like dabs.com's have done, and multiorder search facility, at basically no cost, then I do it. By the time MS remove this facility, they'll replace it with something better, so there's no worries. I don't consider myself a purist. In the spirit of Martin Fowler I guess my ethic is something like "Any fool can write something that works. Good developers write stuff that is verifiable and supportable." That's not dogmatic. It's entirely practical because it reduces TCO for the customer. In this case the problem is not just that it may break in some distant future. It is broken now. That is, even today there are situations where multiple row variable assignments in queries just do not happen. |
|
Since you can't predict whether those situations will arise at runtime you have to take a calculated risk before you implement those |
|
undocumented tricks. Microsoft's history of breaking changes to |
|
undocumented behaviour is against you. I can think of multiple precedents where undefined features have changed or failed in SQL Server service packs, hotfixes and versions. The customer then has to pay the price for development before he can patch his server. |
|
-- David Portas, SQL Server MVP Whenever possible please post enough code to reproduce your problem. Including CREATE TABLE and INSERT statements usually helps. State what version of SQL Server you are using and specify the content of any error messages. SQL Server Books Online: http://msdn2.microsoft.com/library/m...S,SQL.90).aspx -- |
#23
| |||
| |||
|
|
Are you saying my query doesn't work? No? I didn't think so. |
|
Since you can't predict whether those situations will arise at runtime you have to take a calculated risk before you implement those Not true. I actually run them to find out. |
|
I'm well aware of the risks, which is why I have a list of features I use that are periodically checked. This includes documented features. |
#24
| |||
| |||
|
|
drawnai (AT) hotmail (DOT) com wrote: Are you saying my query doesn't work? No? I didn't think so. I'm saying you can't demonstrate that it does. Since you can't predict whether those situations will arise at runtime you have to take a calculated risk before you implement those Not true. I actually run them to find out. Which proves nothing because execution plans can change at runtime. I'm well aware of the risks, which is why I have a list of features I use that are periodically checked. This includes documented features. Proves nothing. See above. |
|
-- David Portas, SQL Server MVP Whenever possible please post enough code to reproduce your problem. Including CREATE TABLE and INSERT statements usually helps. State what version of SQL Server you are using and specify the content of any error messages. SQL Server Books Online: http://msdn2.microsoft.com/library/m...S,SQL.90).aspx -- |
#25
| |||
| |||
|
#26
| |||
| |||
|
#27
| |||
| |||
|
#28
| |||
| |||
|
|
When the day comes that Microsoft runs parallel query against a sequential update, then it will be spotted in UAT (if I haven't already seen it,) and replaced with a cursor or some other cunning tactic. I don't imagine I'll ever see that however, because I don't suppose that Microsoft will rollback the row_number() (Over col1, col2, col3) function in SQL 2010, just to allow it to introduce its new "parallel sequential (tm)" technology - a process that allocates an unknown in advance amount sequential numbers of in parallel. Out of interest, how does one allocate an index in sequence in parallel against a table whose size is unknown at the start of the update without wasting huge resources calculating the tree sizes? Does one mark the entire index as "untouched", then excute massive parallel jobs against parts of it, ensuring never to touch the same record twice? Perhaps, it asks god how big each table leaf root is, and then assigns ranges of numbers of exact size, (taking into account any inserts or deletes that are going to happen, after it starts and before it ends) to ensure that when it distributes the job to it's SMP array, that each row gets a number that is exactly unique, and contiguous. Perhaps you could start at one end of the table, with the length of it (including any intermediate insert/deletes as extrapolated from a small piece of fairy cake), and start at the other end of the same, and then work inwards. My solution would be to simply use magic. This is guaranteed to work. |
#29
| |||
| |||
|
|
drawnai (AT) hotmail (DOT) com wrote: When the day comes that Microsoft runs parallel query against a sequential update, then it will be spotted in UAT (if I haven't already seen it,) and replaced with a cursor or some other cunning tactic. I don't imagine I'll ever see that however, because I don't suppose that Microsoft will rollback the row_number() (Over col1, col2, col3) function in SQL 2010, just to allow it to introduce its new "parallel sequential (tm)" technology - a process that allocates an unknown in advance amount sequential numbers of in parallel. Out of interest, how does one allocate an index in sequence in parallel against a table whose size is unknown at the start of the update without wasting huge resources calculating the tree sizes? Does one mark the entire index as "untouched", then excute massive parallel jobs against parts of it, ensuring never to touch the same record twice? Perhaps, it asks god how big each table leaf root is, and then assigns ranges of numbers of exact size, (taking into account any inserts or deletes that are going to happen, after it starts and before it ends) to ensure that when it distributes the job to it's SMP array, that each row gets a number that is exactly unique, and contiguous. Perhaps you could start at one end of the table, with the length of it (including any intermediate insert/deletes as extrapolated from a small piece of fairy cake), and start at the other end of the same, and then work inwards. My solution would be to simply use magic. This is guaranteed to work. Even sequential scans don't always start at the same place in the index due to enhanced read-ahead (AKA merry-go-round scan). AFAIK that doesn't apply to index updates today but it could perhaps do so in future. That's a good example of something you may be unlikely to spot in a unit test (unless you simulate load). It will likely show up if you test to peak production workload but do you always regression test on that scale for every service pack? Engine changes have gone in SPs before. |
|
-- David Portas, SQL Server MVP Whenever possible please post enough code to reproduce your problem. Including CREATE TABLE and INSERT statements usually helps. State what version of SQL Server you are using and specify the content of any error messages. SQL Server Books Online: http://msdn2.microsoft.com/library/m...S,SQL.90).aspx -- |
#30
| |||
| |||
|
|
Yes; shot you and replace you with a programmer who has read the first 10 pages of **any** RDBMS book. You are posting realllllllly baaaaad questions. Please take some time to catch up over the weekend before you ask us to do your job for you again. SQL is a set-orient language. Tables -- by definition -- have no ordering. That is the nature of a set. Have you ever read Dr. Codd's 12 rules for RDBMS/ Look up the Information Principle: all relationships are shown as values in columns. Ordering is a relationship, so you need a column(s) for it. If you do not know who Dr. Codd is or his rules, then you are like a Geometry student who never heard of Euclid. |
![]() |
| Thread Tools | |
| Display Modes | |
| |