Mysql 和 mysql2 gem 之间的区别是什么

我曾经使用过 mysql gem,但是现在我经常听说 mysql2 gem。而且,它默认包含在 Rails 3.0.xGemfile中。

使用 mysql2宝石有什么区别和优点?

33239 次浏览

Here's a quote from the mysql2 gem page:

Yeah… but why?

Someone: Dude, the Mysql gem works fiiiiiine.

Me: It sure does, but it only hands you nil and strings for field values. Leaving you to convert them into proper Ruby types in Ruby-land - which is slow as balls.

Someone: OK fine, but do_mysql can already give me back values with Ruby objects mapped to MySQL types.

Me: Yep, but its API is considerably more complex and can be ~2x slower.

mysql2 is very much faster than the mysql gem. Also, apart from being effective, it also has more features and is more fun, just like Ruby on Rails.