How to get decent MySQL driver perfomance in Ruby

Posted by Zombies on Stack Overflow See other posts from Stack Overflow or by Zombies
Published on 2010-03-20T18:47:50Z Indexed on 2010/03/20 18:51 UTC
Read the original article Hit count: 568

Filed under:
|
|
|

I notice that I am getting very poor performance for either or both inserts and queries. The queries themselves are basic and can execute with no delay directly from mysql. The ruby script that I wrote is only 1 thread, so only 1 connection is being used, and never closed unless the script is terminated. Pretty basic, I am just trying to insert a lot of rows. There is a look-up or two to get a surrogate key, or to check for duplicates, but the complexity is just O(n). Also, it isn't like there are millions of records, so again the queries themselves take no time to run.

I am using:

  • Ruby 1.9.1
  • Gem/driver:ruby-mysql 2.9.2
  • MySQL 5.1.37-1ubuntu5.1
  • ^ all 32 bit versions on a 32bit ubuntu distro

I am getting about 1-2 inserts per second, pretty slow. I know a lot of people will suggest to change drivers, but that means I have some refactoring and resting to do. So I would really appreciate any help, but please if you do recomend that at least say why you do (eg: if you have used ruby-mysql x.x.x before and found another mysql driver to be better).ruby-mysql 2.9.2

What I would like to know:

  1. How can I improve performance with ruby-mysql 2.9.2
  2. If and only if I cannot do this with ruby-mysql 2.9.2, what should I do?

© Stack Overflow or respective owner

Related posts about mysql

Related posts about ruby