On Monday, December 3, 2012 11:39:40 AM UTC-8, Joshua Hansen wrote:
>
> With a script that's being run about once a day that imports a lot of data
> I'd like to disable indexes temporarily since thousands of lines get
> imported once a day.
>
> How do I set session variables since I presume the connection pool uses
> multiple sessions at once?
>
> For instance, how do I work this in to my Sequel queries before running a
> ton of inserts:
>
> SET FOREIGN_KEY_CHECKS = 0;
> SET UNIQUE_CHECKS = 0;
> SET AUTOCOMMIT = 0;
>
>
The correct way to do this in multithreaded Sequel is:
DB.synchronize do
begin
DB.run("SET FOREIGN_KEY_CHECKS = 0")
DB.run("SET UNIQUE_CHECKS = 0")
DB.run("SET AUTOCOMMIT = 0")
# Your inserts
ensure
# Reset those session variables
end
end
Assuming this script is only run once daily and isn't multithreaded, you
shouldn't need call synchronize directly (but you might want to use the
single threaded pool for additional speed).
Jeremy
--
You received this message because you are subscribed to the Google Groups
"sequel-talk" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/sequel-talk/-/8lePt3E3GBYJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sequel-talk?hl=en.