November 6, 2013 at 9:10 pm
dwain.c (11/6/2013)
Based on cursory review of the information surrounding the quote, I'm in a position of "initial reluctance to agree."I'm thinking that part of that 97% he talks about should be addressed if it can be done without significant overhead to getting the code written and tested.
Need to take a deep dive to see if my initial position holds fast.
Then again, who am I to disagree with the distinguished Dr. Knuth! 😛
I don't disagree with Knuth at all. I do disagree with what many people have erroneously come to believe that he means. If you read the preceding paragraphs from the right column of the preceding page through the text up to the "evil" statement, you'll see why I get so ticked when someone uses the "evil" statement to justify poor design including but not limited to the use of RBAR for small numbers of rows or one-off jobs and using the wrong data-types in the initial design of tables.
Yes, Knuth states that it's a waste of time to spend time to "optimize" one-off jobs and I mostly agree with that. But if you already know a way to have the code run faster and it takes no extra dev time to do so, why would anyone intentionally write it using a slower, "less optimal" method?
That's a subject that I don't believe Knuth spent enough time on... learning and practicing the optimal methods so that they become second nature so that they don't actually take any extra time to incorporate in areas that are known to be troublesome insofar as performance goes. To wit, that's not "premature optimization" in my book. That's knowing the trade and understanding known design problems.
--Jeff Moden
Change is inevitable... Change for the better is not.
November 7, 2013 at 2:52 pm
dwain.c (11/4/2013)
Jeff Moden (11/4/2013)
dwain.c (11/4/2013)
Jeff Moden (11/4/2013)
shashianireddy (11/4/2013)
sql 2008 version ,,nvarchar(MAX)You're using NVARCHAR(MAX) for a housenumber???? In SQL Server 2008???? Why?????
You probably don't release it but you cannot rebuild a clustered index in an Online fashion in SQL Server 2008 if the table contains a blob. This is a totally unneccessary blob.
Yes, yes... I know... all of your character based columns are NVARCHAR(MAX) because someone believes that "Premature optimization is the root of all evil." The problem is no one ever considers such things as what I've just mentioned and even fewer go back and optimize when they're supposed to.
I strongly recommend that someone go fix that table to have the correctly sized datatypes.
Glad to see I'm not the only one that felt that way. Although your feelings seem a bit stronger on the subject. Probably because you're not seeing such nonsense as frequently as I do.
The reason why I don't see such nonsense that often is because I've trained my Developers. I would never allow such a table design to even go into Dev never mind Prod. This is the kind of garbage that some of the automatic front-end designer software does. What really kills me is that one of the products that does it is Microsoft software.
I'm all for the avoidance of prematue optimization but any system or human that creates all NVARCHAR(MAX) or even all NVARCHAR(4000) for all character based columns in a table is way over the top so far as I'm concerned.
Sounds like you have the luxury of an orderly, controlled shop. Congratulations for exercising such strict controls (and being able to)!
I don't use any VARCHAR columns; they're all NVARCHAR, though I do control their sizes in increments of 64 to keep data from being truncated.
I've gotten some feedback that this is inappropriate, but I receive dozens and dozens of Excel files a week that I have to import and make sense of (no control over their generation). Going back to correct Unicode or UTF characters showing up as question marks in VARCHAR columns would put me on Queasy Street. Especially if they make it to a live server.
Since taking advice from a Kevin Boles talk and querying them with N'' I've noticed a definite improvement in performance, but since this looks like a lively talk on the subject...
Am I doing it wrong?! :blush:
November 7, 2013 at 5:37 pm
erikd (11/7/2013)
I don't use any VARCHAR columns; they're all NVARCHAR, though I do control their sizes in increments of 64 to keep data from being truncated.I've gotten some feedback that this is inappropriate, but I receive dozens and dozens of Excel files a week that I have to import and make sense of (no control over their generation). Going back to correct Unicode or UTF characters showing up as question marks in VARCHAR columns would put me on Queasy Street. Especially if they make it to a live server.
Since taking advice from a Kevin Boles talk and querying them with N'' I've noticed a definite improvement in performance, but since this looks like a lively talk on the subject...
Am I doing it wrong?! :blush:
I personally believe in typing columns to what they need to be, so understanding the underlying data is quite important. Of course, when your data is coming in uncontrolled, like through Excel, it is usually better to be safe than sorry.
My thought question: Have you ever been told that your query runs too fast?
My advice:
INDEXing a poor-performing query is like putting sugar on cat food. Yeah, it probably tastes better but are you sure you want to eat it?
The path of least resistance can be a slippery slope. Take care that fixing your fixes of fixes doesn't snowball and end up costing you more than fixing the root cause would have in the first place.
Need to UNPIVOT? Why not CROSS APPLY VALUES instead?[/url]
Since random numbers are too important to be left to chance, let's generate some![/url]
Learn to understand recursive CTEs by example.[/url]
[url url=http://www.sqlservercentral.com/articles/St
December 6, 2013 at 11:52 pm
Msg 245, Level 16, State 1, Line 1
Conversion failed when converting the nvarchar value '17-280' to data type int.
December 7, 2013 at 12:18 am
the first method is ok but ..... it works only if housenumber is integer only ...
it shows error when housenumber mixed wit varchar .............
plz write the code if housenumber is varchar
December 7, 2013 at 3:09 am
shashianireddy (12/7/2013)
the first method is ok but ..... it works only if housenumber is integer only ...it shows error when housenumber mixed wit varchar .............
plz write the code if housenumber is varchar
Please respond to Jeff's earlier post here. He's provided a solution which works well for your given sample data. If it fails with other patterns of house number, then include them in your sample. There's no single algorithm which will work for this.
For better assistance in answering your questions, please read this[/url].
Hidden RBAR: Triangular Joins[/url] / The "Numbers" or "Tally" Table: What it is and how it replaces a loop[/url] Jeff Moden[/url]
December 7, 2013 at 6:42 am
IT SHOWS ERROR
Conversion failed when converting the varchar value '1867 C' to data type int
December 7, 2013 at 8:40 am
shashianireddy (12/7/2013)
IT SHOWS ERRORConversion failed when converting the varchar value '1867 C' to data type int
There's been a lot of code and suggestions on this thread. Please post the readily consumable data and the code that you're currently using that produces this error.
--Jeff Moden
Change is inevitable... Change for the better is not.
December 15, 2013 at 11:07 am
Each one of your five current threads
select quarie between houseno ..........
select only up to first '-' only
display order by like 1,2,3,4,5...............plz write quarie
relate to the same issue. Help us and you will help yourself. Please provide a sample data set which is properly representative of your data. Your data doesn't all look like "3-9-55". If it did, any one of several solutions already posted would work just fine.
Is "3-9-55" just a Hyderabad house number or is it three data elements combined into one?
For better assistance in answering your questions, please read this[/url].
Hidden RBAR: Triangular Joins[/url] / The "Numbers" or "Tally" Table: What it is and how it replaces a loop[/url] Jeff Moden[/url]
Viewing 9 posts - 31 through 38 (of 38 total)
You must be logged in to reply to this topic. Login to reply