And you didn’t ask him why? Should, if he said he has to substantiate. Unless he didn’t know, that he read it somewhere and went off repeating it like a parrot. Anything without foundation should be ignored, so you’re right to ask.
You should use, at first, the most semantic one. Do you want to put a limit? Putting 8000 is an acceptable limit number? Or another number is better, who knows less? If you want no limit, why would you do this?
How optimization can consider the implementation detail of the tool you are using. Today, and for a long time, SQL uses different shapes when the column VARCHAR
It’s up to 8,000 characters or it could be more than that. With this limit the text will be saved as part of the line, and when you can pass it the text is written separately on other pages of DB, and it makes a kind of Join transparent implicit for you, but that has an extra reading cost. It usually has an advantage for cases like this.
Not always keeping large texts together with the normal line can be an optimization, it’s hard to say that, but if the choice of SQL Server is always to separate the text when it can be more than 8000 characters (I can’t say that it always does this) and you know that most texts will be small, so really limiting to 8000 can be a good optimization because it reads everything straight always need to resort to an extra reading of another page in most situations.
For most cases this optimization is silly, but if you have large volumes and certain patterns then you can compensate. You have to measure. But first look at the semantics desired.
Noting that this holds true for SQL Server only, and for the versions up to this date, nothing guarantees that it will always be so, although it is likely, after all has some unofficial documentation about it, so it would have to be very important to change.
It may have some extra implications, as I said is implementation detail.
In general it is good advice, especially now that you know the reason and can make a better decision in each case. It’s about efficiency, effectiveness is something else that’s more complicated to analyze if it is, even more so without context.
Thank you @Maniero, I understand your explanation. When my supervised quickly, together he gave a brief explanation, which I did not understand why I work in another language and sometimes it is not clear to me what he speaks. I lack vocabulary in the other language. So I try to understand the idea of what it is saying and then research what it was trying to give me. And yes, the script that I wrote that my supervisor reviewed was going to treat a huge range of data and it was running for more than five hours. Thanks again.
– Raquel Andrade
And changing it brought measurable gain?
– Maniero
I can’t say, because the script only ran full after the variables were already changed to sweep (8000) and now I no longer have permission to rotate it again in order to make such a test and cure my curiosity.
– Raquel Andrade
It’s a shame, was in the kick if this was effective (which is different from efficiency and effective) or not with respect to doubt.
– Maniero
Yes, it’s a shame. And in the question, I thought efficiency and wrote efficiency. I lose!
– Raquel Andrade