# IR WPF Project, ActiveRecord sqlite3-ironruby writes slow, reads fast

**URL:** <https://www.ruby-forum.com/t/ir-wpf-project-activerecord-sqlite3-ironruby-writes-slow-reads-fast/201393>\
**Category:** IronRuby\
**Created:** [January 6, 2011, 5:19pm UTC](https://www.ruby-forum.com/t/ir-wpf-project-activerecord-sqlite3-ironruby-writes-slow-reads-fast/201393 "2011-01-06T17:19:39Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [January 6, 2011, 5:19pm UTC](https://www.ruby-forum.com/t/ir-wpf-project-activerecord-sqlite3-ironruby-writes-slow-reads-fast/201393/1 "2011-01-06T17:19:39Z")

</div>

Hello,  
I am since some weeks working with IronRuby.I do not consider myself a  
great programmer in neither Ruby or .NET, yet I really love Ruby, and in  
these past few weeks IronRuby and .NET in general has really grown on  
me; very powerful!So first; my gratitude for this amazing product,  
thanks to all who make this possible!  
My project’s available @ Github:  
[https://github.com/sickboy/six-updater-gui](https://github.com/sickboy/six-updater-gui)  
My current issue is that SQLite writes seem to take at least 0.7 seconds  
per write.So if I update 100 records at once in 1 query, it will take  
~0.8s.But also if I update 1 record, it will take ~0.7s…In comparison,  
the same actions with mingw Ruby 1.9.2 (from [RubyInstaller.org](http://RubyInstaller.org)), these  
writes take only about 0.005s  
Reads seem to be okay.  
Is this a known problem? Is there anything that can be done about  
this?Do others see these long delays as well? How about msSQL  
(/Express)?

Not sure if I should create a seperate mail thread for this;The second  
problem i’m having is that when I load a database model with  
ActiveRecord 2.3.8 into a BindingList, and that to a BindingSource, and  
assign it to a DataGridView, everything is fine.When I use ActiveRecord  
3.03, I get “A singleton class has no underlying system type”. Unless I  
don’t add records to the binding list, before assigning the  
BindingSource as data\_source of the DataGridView, and instead, add  
records to the binding list after assigning the data\_source.I am not  
sure how I should debug this problem.

Lastly I have the feeling (based on timing results in my logs) that  
processing IronRuby scripts is faster when they run through the ir.exe  
interpreter, than when they are executed in an engine from within a c#  
app.Could that be because certain optimizations are enabled in ir.exe,  
or something similair?

Thanks for your time!

---

<div class="post-metadata">

**Author:** ![Sick\_Boy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/3d9bf3/32.png) [@Sick\_Boy](https://www.ruby-forum.com/u/Sick_Boy)\
**Post date:** [January 8, 2011, 1:03pm UTC](https://www.ruby-forum.com/t/ir-wpf-project-activerecord-sqlite3-ironruby-writes-slow-reads-fast/201393/2 "2011-01-08T13:03:26Z")

</div>

I went out of my way and decided to have a look at updating the SQlite  
dll.  
It seems the interface has changed since sqlite3-ironruby gem release.  
I have downloaded and put the Community.CsharpSqlite.dll in the native  
folder:[Google Code Archive - Long-term storage for Google Code Project Hosting.](http://code.google.com/p/csharp-sqlite/downloads/list?can=1&q=&colspec=Filename+Summary+Uploaded+ReleaseDate+Size+DownloadCount)  
Then I have adjusted driver.rb to:  
[http://pastebin.com/diff.php?i=7e522Rvs](http://pastebin.com/diff.php?i=7e522Rvs)  
Most things seem to just work, and it’s blazing fast now, about as fast  
as Ruby 1.9.2’s sqlite3 performance!  
I thought i’d let you know in case experiencing similair issues 🙂

From: removed\_email\_address@domain.invalid  
To: removed\_email\_address@domain.invalid  
Date: Thu, 6 Jan 2011 15:51:46 +0000  
Subject: [Ironruby-core] IR WPF Project, ActiveRecord sqlite3-ironruby  
writes slow, reads fast

Hello,  
I am since some weeks working with IronRuby.I do not consider myself a  
great programmer in neither Ruby or .NET, yet I really love Ruby, and in  
these past few weeks IronRuby and .NET in general has really grown on  
me; very powerful!So first; my gratitude for this amazing product,  
thanks to all who make this possible!  
My project’s available @ Github:  
[https://github.com/sickboy/six-updater-gui](https://github.com/sickboy/six-updater-gui)  
My current issue is that SQLite writes seem to take at least 0.7 seconds  
per write.So if I update 100 records at once in 1 query, it will take  
~0.8s.But also if I update 1 record, it will take ~0.7s…In comparison,  
the same actions with mingw Ruby 1.9.2 (from [RubyInstaller.org](http://RubyInstaller.org)), these  
writes take only about 0.005s  
Reads seem to be okay.  
Is this a known problem? Is there anything that can be done about  
this?Do others see these long delays as well? How about msSQL  
(/Express)?

Not sure if I should create a seperate mail thread for this;The second  
problem i’m having is that when I load a database model with  
ActiveRecord 2.3.8 into a BindingList, and that to a BindingSource, and  
assign it to a DataGridView, everything is fine.When I use ActiveRecord  
3.03, I get “A singleton class has no underlying system type”. Unless I  
don’t add records to the binding list, before assigning the  
BindingSource as data\_source of the DataGridView, and instead, add  
records to the binding list after assigning the data\_source.I am not  
sure how I should debug this problem.

Lastly I have the feeling (based on timing results in my logs) that  
processing IronRuby scripts is faster when they run through the ir.exe  
interpreter, than when they are executed in an engine from within a c#  
app.Could that be because certain optimizations are enabled in ir.exe,  
or something similair?

Thanks for your time!

---

<div class="post-metadata">

**Author:** ![Sick\_Boy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/3d9bf3/32.png) [@Sick\_Boy](https://www.ruby-forum.com/u/Sick_Boy)\
**Post date:** [January 9, 2011, 1:21am UTC](https://www.ruby-forum.com/t/ir-wpf-project-activerecord-sqlite3-ironruby-writes-slow-reads-fast/201393/3 "2011-01-09T01:21:30Z")

</div>

Only problem i’ve ran into with this method for now has been the usage  
of System::Int64 for Primary keys.  
In a join table it was storing the yaml representation of the Int64  
object instead of the proper Integer value,  
as a quick patch I’ve applied the following but i’m sure there is a  
better safer way;  
class System::Int64  
def to\_i; self.to\_s.to\_i; end  
end

From: removed\_email\_address@domain.invalid  
To: removed\_email\_address@domain.invalid  
Date: Sat, 8 Jan 2011 11:53:05 +0000  
Subject: Re: [Ironruby-core] IR WPF Project, ActiveRecord  
sqlite3-ironruby writes slow, reads fast

I went out of my way and decided to have a look at updating the SQlite  
dll.  
It seems the interface has changed since sqlite3-ironruby gem release.  
I have downloaded and put the Community.CsharpSqlite.dll in the native  
folder:[Google Code Archive - Long-term storage for Google Code Project Hosting.](http://code.google.com/p/csharp-sqlite/downloads/list?can=1&q=&colspec=Filename+Summary+Uploaded+ReleaseDate+Size+DownloadCount)  
Then I have adjusted driver.rb to:  
[http://pastebin.com/diff.php?i=7e522Rvs](http://pastebin.com/diff.php?i=7e522Rvs)  
Most things seem to just work, and it’s blazing fast now, about as fast  
as Ruby 1.9.2’s sqlite3 performance!  
I thought i’d let you know in case experiencing similair issues 🙂

From: removed\_email\_address@domain.invalid  
To: removed\_email\_address@domain.invalid  
Date: Thu, 6 Jan 2011 15:51:46 +0000  
Subject: [Ironruby-core] IR WPF Project, ActiveRecord sqlite3-ironruby  
writes slow, reads fast

Hello,  
I am since some weeks working with IronRuby.I do not consider myself a  
great programmer in neither Ruby or .NET, yet I really love Ruby, and in  
these past few weeks IronRuby and .NET in general has really grown on  
me; very powerful!So first; my gratitude for this amazing product,  
thanks to all who make this possible!  
My project’s available @ Github:  
[https://github.com/sickboy/six-updater-gui](https://github.com/sickboy/six-updater-gui)  
My current issue is that SQLite writes seem to take at least 0.7 seconds  
per write.So if I update 100 records at once in 1 query, it will take  
~0.8s.But also if I update 1 record, it will take ~0.7s…In comparison,  
the same actions with mingw Ruby 1.9.2 (from [RubyInstaller.org](http://RubyInstaller.org)), these  
writes take only about 0.005s  
Reads seem to be okay.  
Is this a known problem? Is there anything that can be done about  
this?Do others see these long delays as well? How about msSQL  
(/Express)?

Not sure if I should create a seperate mail thread for this;The second  
problem i’m having is that when I load a database model with  
ActiveRecord 2.3.8 into a BindingList, and that to a BindingSource, and  
assign it to a DataGridView, everything is fine.When I use ActiveRecord  
3.03, I get “A singleton class has no underlying system type”. Unless I  
don’t add records to the binding list, before assigning the  
BindingSource as data\_source of the DataGridView, and instead, add  
records to the binding list after assigning the data\_source.I am not  
sure how I should debug this problem.

Lastly I have the feeling (based on timing results in my logs) that  
processing IronRuby scripts is faster when they run through the ir.exe  
interpreter, than when they are executed in an engine from within a c#  
app.Could that be because certain optimizations are enabled in ir.exe,  
or something similair?

Thanks for your time!

* * *

Ironruby-core mailing list  
removed\_email\_address@domain.invalid  
[http://rubyforge.org/mailman/listinfo/ironruby-core](http://rubyforge.org/mailman/listinfo/ironruby-core)

---

<div class="post-metadata">

**Author:** ![Sick\_Boy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/3d9bf3/32.png) [@Sick\_Boy](https://www.ruby-forum.com/u/Sick_Boy)\
**Post date:** [January 9, 2011, 1:47am UTC](https://www.ruby-forum.com/t/ir-wpf-project-activerecord-sqlite3-ironruby-writes-slow-reads-fast/201393/4 "2011-01-09T01:47:47Z")

</div>

The driver should convert Int64 to Bignum, using e.g. Kernel#Integer:

> > > i64 = System::Int64.new(1000000000000)  
> > > =\> 1000000000000 (Int64)  
> > > Integer(i64)  
> > > =\> 1000000000000  
> > > Integer(i64).class  
> > > =\> Bignum

Tomas

From: [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
[[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)] On Behalf Of Sick Boy  
Sent: Saturday, January 08, 2011 3:58 PM  
To: [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Subject: Re: [Ironruby-core] IR WPF Project, ActiveRecord  
sqlite3-ironruby writes slow, reads fast

Only problem i’ve ran into with this method for now has been the usage  
of System::Int64 for Primary keys.

In a join table it was storing the yaml representation of the Int64  
object instead of the proper Integer value,

as a quick patch I’ve applied the following but i’m sure there is a  
better safer way;

class System::Int64

def to\_i; self.to\_s.to\_i; end

end

* * *

From: [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
To: [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Date: Sat, 8 Jan 2011 11:53:05 +0000  
Subject: Re: [Ironruby-core] IR WPF Project, ActiveRecord  
sqlite3-ironruby writes slow, reads fast

I went out of my way and decided to have a look at updating the SQlite  
dll.

It seems the interface has changed since sqlite3-ironruby gem release.

I have downloaded and put the Community.CsharpSqlite.dll in the native  
folder:

> **[Google Code Archive - Long-term storage for Google Code Project Hosting.](https://code.google.com/archive/p/csharp-sqlite/downloads)**

Then I have adjusted driver.rb to:  
[http://pastebin.com/diff.php?i=7e522Rvs](http://pastebin.com/diff.php?i=7e522Rvs)

Most things seem to just work, and it’s blazing fast now, about as fast  
as Ruby 1.9.2’s sqlite3 performance!

I thought i’d let you know in case experiencing similair issues 🙂

* * *

From: [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
To: [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Date: Thu, 6 Jan 2011 15:51:46 +0000  
Subject: [Ironruby-core] IR WPF Project, ActiveRecord sqlite3-ironruby  
writes slow, reads fast  
Hello,

I am since some weeks working with IronRuby.  
I do not consider myself a great programmer in neither Ruby or .NET, yet  
I really love Ruby, and in these past few weeks IronRuby and .NET in  
general has really grown on me; very powerful!  
So first; my gratitude for this amazing product, thanks to all who make  
this possible!

My project’s available @ Github:  
[https://github.com/sickboy/six-updater-gui](https://github.com/sickboy/six-updater-gui)

My current issue is that SQLite writes seem to take at least 0.7 seconds  
per write.  
So if I update 100 records at once in 1 query, it will take ~0.8s.  
But also if I update 1 record, it will take ~0.7s..  
In comparison, the same actions with mingw Ruby 1.9.2 (from  
[RubyInstaller.org](http://RubyInstaller.org)), these writes take only about 0.005s

Reads seem to be okay.

Is this a known problem? Is there anything that can be done about this?  
Do others see these long delays as well? How about msSQL (/Express)?

Not sure if I should create a seperate mail thread for this;  
The second problem i’m having is that when I load a database model with  
ActiveRecord 2.3.8 into a BindingList, and that to a BindingSource, and  
assign it to a DataGridView, everything is fine.  
When I use ActiveRecord 3.03, I get “A singleton class has no underlying  
system type”. Unless I don’t add records to the binding list, before  
assigning the BindingSource as data\_source of the DataGridView, and  
instead, add records to the binding list after assigning the  
data\_source.  
I am not sure how I should debug this problem.

Lastly I have the feeling (based on timing results in my logs) that  
processing IronRuby scripts is faster when they run through the ir.exe  
interpreter, than when they are executed in an engine from within a c#  
app.  
Could that be because certain optimizations are enabled in ir.exe, or  
something similair?

Thanks for your time!

\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_ Ironruby-core mailing  
list [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
[http://rubyforge.org/mailman/listinfo/ironruby-core](http://rubyforge.org/mailman/listinfo/ironruby-core)

\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_ Ironruby-core mailing  
list [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
[http://rubyforge.org/mailman/listinfo/ironruby-core](http://rubyforge.org/mailman/listinfo/ironruby-core)
