Possible to set "PRAGMA default_synchronous=OFF" for my sqlite connection via AR?


#1

Hey All,

I’m using ActiveRecord w/the sqlite3 adapter and finding it slow for
my use. After reading _whytheluckystiff’s
http://whytheluckystiff.net/articles/aQuickGuideToSQLite.html I
wondered if it’s possible to configure the default_synchronous option
on an ActiveRecord connection. Does anyone know if this is possible?

I tried

ActiveRecord::Base.establish_connection(
:adapter => “sqlite3”,
:database => STORE + “test.db”,
:options => “PRAGMA default_synchronous=OFF”
)

and

ActiveRecord::Base.establish_connection(
:adapter => “sqlite3”,
:database => STORE + “test.db”,
:default_synchronous => “OFF”
)

and didn’t get any errors, but I’m not seeing any speed increase
either (also, it looks like I can pass any gobbledygook in as :options
and not get any errors). So I’m hoping I’m doing it wrong and someone
here can tell me how to do it right.

Many thanks!

-Roy


#2

If nothing else, it appears that you can do:

c = ::ActiveRecord::Base.connection
c.execute(“PRAGMA default_synchronous=OFF”)

I’m not sure if there’s a way to pass this as an option to
AR:Base.establish_connection.

Doing this gives me a a bit of a speed boost (that’s perceived–I’m
not actually measuring or anything) but not the rip-roaring one I was
hoping for… :frowning: