What is the difference between mysql and mysql2 gem

I used to work with the mysql gem, but often nowadays I hear about the mysql2 . It is also included in the default Rails 3.0.x in Rails 3.0.x

What is the difference and benefits of using the mysql2 ?

+65
ruby mysql ruby-on-rails rubygems
Mar 23 2018-11-11T00:
source share
2 answers

Here is a quote from the mysql2 gem page :

Yes ... but why?

Someone: Dude, Mysql fiiiiiine gem.

Me: Of course, but it's just you nil hands and strings for field values. Leaving you to convert them to the correct Ruby types in Ruby-land - which are slow as balls.

Someone: fine, but do_mysql may already have returned values ​​to me with Ruby objects mapped to MySQL types.

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

+74
Mar 23 2018-11-21T00:
source share

mysql2 is much faster than the mysql gem. In addition to being effective, it also has more features and is more interesting, like Ruby on Rails.

+8
Mar 23 2018-11-21T00:
source share



All Articles