0

我需要在多对多关系VARCHAR中做出选择INT

做起来更快IN('1','21','311')还是IN(1,21,311)Mysql中更快?

4

1 回答 1

1

You'll want to use integers whenever possible since their representation is fixed length, four bytes by default, and comparisons are done with a single operation. Indexing and comparing strings is always more expensive, but the longer the strings get, the bigger the difference.

In your example here, which uses trivially small numbers, they might perform about the same. With real-world numbers that have six or seven digits, though, you'll see a much bigger difference.

于 2013-09-26T14:42:34.663 回答