Is it better to have a field status enum('active', 'hidden', 'deleted')
OR status tinyint(3)
with a lookup table? Assume that status can take only one value at a time.
是否最好有一个字段状态枚举('active', 'hidden', 'delete ')或状态tinyint(3)和查找表?假设状态一次只能取一个值。
In particular, I am interested in knowing if operations on enum
are significantly slower than or as fast as operations on int
?
特别是,我想知道enum上的操作是明显地慢于还是快于int上的操作?
There is a related question on SO but:
关于这个有一个相关的问题,但是
- It does not discuss performance at all;
- 它根本不讨论性能;
- There is very little explanation on why one approach is better than the other.
- 对于为什么一种方法比另一种更好,几乎没有什么解释。
1 个解决方案
#1
20
This is already discussed on popular http://www.mysqlperformanceblog.com, check out this post:
这已经在流行的http://www.mysqlperformanceblog.com上讨论过了,请查看以下文章:
- Enum Fields VS Varchar VS Int + Joined table: What is Faster?
- Enum字段VS Varchar VS Int + join table:什么更快?
#1
20
This is already discussed on popular http://www.mysqlperformanceblog.com, check out this post:
这已经在流行的http://www.mysqlperformanceblog.com上讨论过了,请查看以下文章:
- Enum Fields VS Varchar VS Int + Joined table: What is Faster?
- Enum字段VS Varchar VS Int + join table:什么更快?