On Sep 8, 1:28 am, Iñaki Baz Castillo <[email protected]> wrote: > Hi, when using a prepared statement (using MySQL adapter) containing > two or more variables, Sequel does a "SET" query for each variable, > this is: > > #prepare: > PREPARE ps FROM "SELECT etag FROM storage WHERE username = ? AND > domain = ?"; > > #call: > SET @u = "ibc"; > SET @d = "example.org"; > EXECUTE ps USING @u, @d; > > This could be improved by using a single SET query (and it works): > > #prepare: > PREPARE ps FROM "SELECT etag FROM storage WHERE username = ? AND > domain = ?"; > > #call: > SET @u = "ibc", @d = "example.org"; > EXECUTE ps USING @u, @d; > > It reduces the CPU used by MySQL in high load environments (tested > with some benchmarks). > > I attach a patch for "lib/sequel/adapters/mysql.rb" which improves the > performance as explained above. Hope it's useful.
Looks good, tests well, so applied: http://github.com/jeremyevans/sequel/commit/9bf33b6cee2a52683f9e0f5ee3e8f116ec871d57 I tried a variant that set that variables and executed the prepared statement in a single call to _execute, but it failed some of the integration tests. It looked to be safe for selects, but did not return the correct values for delete/insert/update. Jeremy --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sequel-talk" group. 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 -~----------~----~----~----~------~----~------~--~---
