Why not use varchar(max)?

后端 未结 8 2006
广开言路
广开言路 2020-12-05 17:03

I\'m a bit old school when it comes to database design, so I\'m totally for using the correct data sizes in columns. However, when reviewing a database for a friend, I notic

8条回答
  •  南方客
    南方客 (楼主)
    2020-12-05 17:37

    Redgate wrote a great article about this.
    https://www.red-gate.com/simple-talk/sql/database-administration/whats-the-point-of-using-varcharn-anymore/

    Conclusions

    • Where appropriate, use VARCHAR(n) over VARCHAR(MAX) for reasons of good design if not performance benefits, and because VARCHAR(MAX) data does not compress
    • Storing large strings takes longer than storing small strings.
    • Updating an in-row VARCHAR(MAX) value from below 8,000 to over 8,000 will be relatively slow, but the difference for a single transaction will likely not be measurable.
    • Updating an in-row VARCHAR(MAX) value from over 8,000 to below 8,000 will be faster than if the table is set to store data out-of-row.
    • Using the out-of-row option for VARCHAR(MAX) will cause slower writes until the strings are very long.

提交回复
热议问题