Is Varchar (128) better than varchar (100)

Quick question. Does it matter from the point of storing data if I will use decimal field limits or hexadecimal (say 16,32,64 instead of 10,20,50)?

I ask because I wonder if this will have anything to do with clusters on HDD?


VARCHAR(128) is better than VARCHAR(100) if you need to store strings longer than 100 bytes.

Otherwise, there is very little to choose between them; you should choose the one that better fits the maximum length of the data you might need to store. You won’t be able to measure the performance difference between them. All else apart, the DBMS probably only stores the data you send, so if your average string is, say, 16 bytes, it will only use 16 (or, more likely, 17 – allowing 1 byte for storing the length) bytes on disk. The bigger size might affect the calculation of how many rows can fit on a page – detrimentally. So choosing the smallest size that is adequate makes sense – waste not, want not.

So, in summary, there is precious little difference between the two in terms of performance or disk usage, and aligning to convenient binary boundaries doesn’t really make a difference.

Hello, buddy!稿源:Hello, buddy! (源链) | 关于 | 阅读提示

本站遵循[CC BY-NC-SA 4.0]。如您有版权、意见投诉等问题,请通过eMail联系我们处理。
酷辣虫 » 后端存储 » Is Varchar (128) better than varchar (100)

喜欢 (0)or分享给?

专业 x 专注 x 聚合 x 分享 CC BY-NC-SA 4.0

使用声明 | 英豪名录