Roy Pardee
2009-May-16  05:19 UTC
possible to set "PRAGMA default_synchronous=OFF" for my sqlite connection via AR?
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
Roy Pardee
2009-May-18  00:44 UTC
Re: possible to set "PRAGMA default_synchronous=OFF" for my sqlite connection via AR?
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... :(
On May 15, 10:19 pm, Roy Pardee
<rpar...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> Hey All,
>
> I''m using ActiveRecord w/the sqlite3 adapter and finding it slow
for
> my use.  After reading
_whytheluckystiff''shttp://whytheluckystiff.net/articles/aQuickGuideToSQLite.htmlI
> 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