4 ms·
Sorry for the late reply! > Why wait for all of the slave databases to be in sync? If at least one is in sync, > can you get all database interactions
by YorickPeterse 9y ago
Sorry for the late reply!
> Why wait for all of the slave databases to be in sync? If at least one is in sync,
> can you get all database interactions in the application to the valid subset?
If queries fail on the replica we'll cycle through the available replicas until we have one that works. If we didn't wait for all to be in sync it could in theory be possible we'd retry our query on a host that does not yet have the data, though this would be very unlikely. So basically we're being a bit paranoid here.
> Why escape the input and use string interpolation instead of a parameter?
Rails doesn't really provide an easy way of doing this unfortunately. That is, to run raw queries you'll use something like this:
ActiveRecord::Base.connection.execute 'your query here'
This particular API doesn't support passing any parameters, so you have to resort to manually escaping data and using string interpolation.