# Comparison of rails and java for mysql

**URL:** <https://www.ruby-forum.com/t/comparison-of-rails-and-java-for-mysql/116424>\
**Category:** Rails\
**Created:** [October 5, 2007, 11:19am UTC](https://www.ruby-forum.com/t/comparison-of-rails-and-java-for-mysql/116424 "2007-10-05T11:19:55Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ghee\_wooi\_O](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/f475e1/32.png) [@Ghee\_wooi\_O](https://www.ruby-forum.com/u/Ghee_wooi_O)\
**Post date:** [October 5, 2007, 11:19am UTC](https://www.ruby-forum.com/t/comparison-of-rails-and-java-for-mysql/116424/1 "2007-10-05T11:19:55Z")

</div>

hi,

I had create a sample test to try out rails performance on mysql

I had created one rake task to load a 79440 record (almost 3.84MB) into  
mysql database (innodb) and another is a java version (JDBC), i found  
that the performance is alomost the same if the table’s engine is  
Innodb. (slow, is that anyway to improve the performance? )

since the table is only for read, so of cause MYISAM is more suitable.  
so with the same code, but difference type of engine (now is MYISAM),  
and the result i get look like this :

14 seconds - java  
1 min 8 seconds - ruby on rails - directly execute sql statement.  
more then 1 minutes - ruby on rails, which create a object, insert  
value, and  
obj.save! it, however, i got no patient to finish  
it, it  
is pretty slow.

all code is run in same machine (window XP, 1.73GHz intel) mysql version  
5.0, ruby use “mysql” adapter, java use JDBC adapter.

all code is in attachement.  
pre condition : mysql5 is install, jdbc driver install, java code point  
to  
correct database.

instructions : create a rails project and unzip the zip file to the  
lib/tasks directory. download and unzip the sample file to load into  
same dir too. this sample can get from  
[http://ip-to-country.webhosting.info/downloads/ip-to-country.csv.zip](http://ip-to-country.webhosting.info/downloads/ip-to-country.csv.zip)

1. how can I tweak (or should i tweak) the performance of rails ?
2. why the InnoDB is so slow (is that because of transaction overhead )  
?
3. is this a correct way to test performance ?

thank for help.  
kiwi.

---

<div class="post-metadata">

**Author:** ![Ghee\_wooi\_O](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/f475e1/32.png) [@Ghee\_wooi\_O](https://www.ruby-forum.com/u/Ghee_wooi_O)\
**Post date:** [October 5, 2007, 11:51am UTC](https://www.ruby-forum.com/t/comparison-of-rails-and-java-for-mysql/116424/2 "2007-10-05T11:51:51Z")

</div>

Ghee wooi Ong wrote:

> 1. how can I tweak (or should i tweak) the performance of rails ?
> 2. why the InnoDB is so slow (is that because of transaction overhead )  
> ?
> 3. is this a correct way to test performance ?
> 
> thank for help.  
> kiwi.

1. no you shouldnt
2. dont know
3. well if thats what your using are doing (importing 8000 reorcrds in a  
db), then yeah…speed of development/maintenance is more important than  
speed of db inserts

Mikkel

---

<div class="post-metadata">

**Author:** ![Ghee\_wooi\_O](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/f475e1/32.png) [@Ghee\_wooi\_O](https://www.ruby-forum.com/u/Ghee_wooi_O)\
**Post date:** [October 5, 2007, 12:07pm UTC](https://www.ruby-forum.com/t/comparison-of-rails-and-java-for-mysql/116424/3 "2007-10-05T12:07:06Z")

</div>

Mikkel B. wrote:

> 1. no you shouldnt
> 2. dont know
> 3. well if thats what your using are doing (importing 8000 reorcrds in a  
> db), then yeah…speed of development/maintenance is more important than  
> speed of db inserts
> 
> Mikkel

“more then 1 minutes - ruby on rails, which create a object, insert  
value, and obj.save! it, however, i got no patient to finish it, it is  
pretty slow.”

for test above, i think the code should simply like this (result of 1  
min and 8 sec is using SQL directly ). accept the performance is slow.

I like the way ruby on rails doing web development, but unfortunately  
that i more familiar with java, and in fact java for me is more easy to  
read and code. (accept to many xml files) and ruby i only learn 3 month.

hence maintenance of ruby could be my problem too ☹

but if in the real life if the insert is quite haeavy, then is that any  
way to fix the performance issue ?

---

<div class="post-metadata">

**Author:** ![Ghee\_wooi\_O](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/f475e1/32.png) [@Ghee\_wooi\_O](https://www.ruby-forum.com/u/Ghee_wooi_O)\
**Post date:** [October 5, 2007, 12:25pm UTC](https://www.ruby-forum.com/t/comparison-of-rails-and-java-for-mysql/116424/4 "2007-10-05T12:25:45Z")

</div>

On 5 Oct 2007, at 11:07, Ghee wooi Ong wrote:

> but if in the real life if the insert is quite haeavy, then is that  
> any  
> way to fix the performance issue ?

Can you bulk insert stuff - ie write sql to insert more than one  
record in one go? IIRC there is a plugin (ActiveRecord Extensions)  
that helps with this

Fred

---

<div class="post-metadata">

**Author:** ![Ghee\_wooi\_O](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/f475e1/32.png) [@Ghee\_wooi\_O](https://www.ruby-forum.com/u/Ghee_wooi_O)\
**Post date:** [October 5, 2007, 2:08pm UTC](https://www.ruby-forum.com/t/comparison-of-rails-and-java-for-mysql/116424/5 "2007-10-05T14:08:59Z")

</div>

Frederick C. wrote:

> On 5 Oct 2007, at 11:07, Ghee wooi Ong wrote:
> 
> > but if in the real life if the insert is quite haeavy, then is that  
> > any  
> > way to fix the performance issue ?
> 
> Can you bulk insert stuff - ie write sql to insert more than one  
> record in one go? IIRC there is a plugin (ActiveRecord Extensions)  
> that helps with this
> 
> Fred

I think probably yes…my intend is to load/initialize database before  
the application start.

---

<div class="post-metadata">

**Author:** ![Ghee\_wooi\_O](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/f475e1/32.png) [@Ghee\_wooi\_O](https://www.ruby-forum.com/u/Ghee_wooi_O)\
**Post date:** [October 5, 2007, 2:11pm UTC](https://www.ruby-forum.com/t/comparison-of-rails-and-java-for-mysql/116424/6 "2007-10-05T14:11:21Z")

</div>

CCH wrote:

> Hi Ghee Wooi
> 
> I have a e-CRM apps with more than 200 tables.  
> In particular I have a time-sheet module with more than 40,000 records
> 
> For me to display a grid, it takes 2-3 seconds and to insert a record  
> into the same table also 2-3 seconds 🙂
> 
> Is this fast enough for you ?
> 
> BTW, are you a fellow Malaysian ?
> 
> On Oct 5, 6:07 pm, Ghee wooi Ong [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

hm…I think is fast enough. of coz depend on the intend of the app  
itself.

yes, i’m from malaysia. you also from malaysia ?

---

<div class="post-metadata">

**Author:** ![Ghee\_wooi\_O](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/f475e1/32.png) [@Ghee\_wooi\_O](https://www.ruby-forum.com/u/Ghee_wooi_O)\
**Post date:** [October 5, 2007, 12:34pm UTC](https://www.ruby-forum.com/t/comparison-of-rails-and-java-for-mysql/116424/7 "2007-10-05T12:34:33Z")

</div>

Hi Ghee Wooi

I have a e-CRM apps with more than 200 tables.  
In particular I have a time-sheet module with more than 40,000 records

For me to display a grid, it takes 2-3 seconds and to insert a record  
into the same table also 2-3 seconds 🙂

Is this fast enough for you ?

BTW, are you a fellow Malaysian ?

On Oct 5, 6:07 pm, Ghee wooi Ong [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![Ghee\_wooi\_O](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/f475e1/32.png) [@Ghee\_wooi\_O](https://www.ruby-forum.com/u/Ghee_wooi_O)\
**Post date:** [October 5, 2007, 3:44pm UTC](https://www.ruby-forum.com/t/comparison-of-rails-and-java-for-mysql/116424/8 "2007-10-05T15:44:52Z")

</div>

Hi Ghee Wooi

Yes, I am a fellow Malaysian !

---

<div class="post-metadata">

**Author:** ![Ghee\_wooi\_O](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/f475e1/32.png) [@Ghee\_wooi\_O](https://www.ruby-forum.com/u/Ghee_wooi_O)\
**Post date:** [October 8, 2007, 3:48am UTC](https://www.ruby-forum.com/t/comparison-of-rails-and-java-for-mysql/116424/9 "2007-10-08T03:48:02Z")

</div>

CCH wrote:

> Hi Ghee Wooi
> 
> Yes, I am a fellow Malaysian !

weird…how u know i from Malaysia u know me ??
