Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Using VARCHAR(MAX) still seems to have a significant performance impact, however - http://richardlees.blogspot.com/2010/07/varcharmax-performan... - perhaps the fact it has to check whether the varchar exceeds 8192?


It doesn't just have to check the length of that one field - it needs to check that the whole row wouldn't pass the per-row length limit even if the field itself doesn't.

[N]VARCHAR(MAX) columns can lead to greater page tearing and other performance issues over time if their value is changed between a size that would fit in-row and a size that won't too - so as well as the hit on INSERT/UPDATE performance there may be a (less significant) hit on read performance over time too, on top of the slight hit from simply needing to check where the data is and go find another page if it isn't in-row.

For the most part [N]VARCHAR(MAX) should be used as a more efficient (and far more convenient) replacement for [N]TEXT.

It should only be used as a replacement for [N]VARCHAR(<something>) when the data in the column may need to break the ~4000 characters mark (for NVARCHAR, the limit is ~8000 characters in the case of VARCHAR) or when the total bytes for a row will.




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: