简体   繁体   English

如果在MYSQL中使用按位运算,性能会变差吗?

[英]Will the performance be worse if bitwise operations are used in MYSQL?

There are several boolean columns in one table. 一个表中有几个布尔列。 For convenience in my code, I want to use one column to replace all of them. 为了方便起见,我想使用一列替换所有列。 In the new column, each bit represents an original boolean column. 在新列中,每个位代表一个原始的布尔列。 But if I do like this, I must do bitwise operation in the where clause, so I can't use index for it. 但是,如果我喜欢这样做,则必须在where子句中执行按位运算,因此无法对其使用索引。

Will the performance be worse if bitwise operations are used in MYSQL? 如果在MYSQL中使用按位运算,性能会变差吗?

I must do bitwise operation in the where clause, so I can't use index for it.

You answered your own question. 你是在自问自答。 If your query does not use an index, it means mysql will have to check every actual value stored to see if it matches, which will be a lot slower. 如果您的查询未使用索引,则意味着mysql将必须检查存储的每个实际值以查看其是否匹配,这会慢很多。

您已经回答了您的问题- so I can't use an index for it -是的,在大多数情况下,性能会受到损害。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM