I need to create a column in my database that will contain serialized data. Should I pick a string column or a text column for that?
我需要在我的数据库中创建一个包含序列化数据的列。我应该选择字符串列还是文本列?
At first I would pick text because of the string limited size, but on a second thought, would it have an impact on performance? How should I decide in between string and text?
起初我会选择文本,因为字符串有限的大小,但在第二个想法,它会对性能产生影响吗?我应该如何在字符串和文本之间做出决定?
1 个解决方案
#1
5
Unless you're 100% certain that the serialized data will be less than the maximum size of a VARCHAR column in the database you should use text. Text columns also have limits depending on your database but in general should be sufficiently large.
除非您100%确定序列化数据将小于数据库中VARCHAR列的最大大小,否则应使用文本。文本列也有限制,具体取决于您的数据库,但通常应该足够大。
If you're using Postgresql I'd suggest taking a look at HStore.
如果您正在使用Postgresql,我建议您查看HStore。
#1
5
Unless you're 100% certain that the serialized data will be less than the maximum size of a VARCHAR column in the database you should use text. Text columns also have limits depending on your database but in general should be sufficiently large.
除非您100%确定序列化数据将小于数据库中VARCHAR列的最大大小,否则应使用文本。文本列也有限制,具体取决于您的数据库,但通常应该足够大。
If you're using Postgresql I'd suggest taking a look at HStore.
如果您正在使用Postgresql,我建议您查看HStore。