June 9, 2016 at 5:22 am
A CHAR will always be the same length. That may not be what they really want, most likely it is a hold over from previous (older) way of doing it.
June 9, 2016 at 5:25 am
If n is small, it can be more efficient to use char(n). The storage requirement for varchar(n) includes a two-byte overhead to handle the variable length.
John
June 9, 2016 at 7:53 am
Multiple possible reasons:
1. They don't know better and don't have a good reason
2. If the length variation falls in certain patterns, fixed-width stores more efficiently because of the 2-byte variable-length metadata overhead
3. Fixed-width columns reduce page-splits and clustered index fragmentation because they don't suddenly get updated to a length that requires moving the row to a fresh page
There may be other reasons, but those are the ones I can think of easily.
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply