aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/arel/visitors/mysql.rb
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2018-10-10 05:31:20 +0900
committerRyuta Kamizono <kamipo@gmail.com>2018-10-10 05:31:20 +0900
commit92ccb7c75fd0d07479ea3b458b405b8e6667e05f (patch)
tree5b68a28c358ebe0009e41c4544eba6729db363b9 /activerecord/lib/arel/visitors/mysql.rb
parent3101a4136bd62787e252d2658eee23001036fa0f (diff)
downloadrails-92ccb7c75fd0d07479ea3b458b405b8e6667e05f.tar.gz
rails-92ccb7c75fd0d07479ea3b458b405b8e6667e05f.tar.bz2
rails-92ccb7c75fd0d07479ea3b458b405b8e6667e05f.zip
Improve DELETE with JOIN handling to avoid subqueries if possible
Before: ``` Pet Destroy (0.8ms) DELETE FROM `pets` WHERE `pets`.`pet_id` IN (SELECT `pet_id` FROM (SELECT DISTINCT `pets`.`pet_id` FROM `pets` LEFT OUTER JOIN `toys` ON `toys`.`pet_id` = `pets`.`pet_id` WHERE `toys`.`name` = ?) AS __active_record_temp) [["name", "Bone"]] ``` After: ``` Pet Destroy (1.0ms) DELETE `pets` FROM `pets` LEFT OUTER JOIN `toys` ON `toys`.`pet_id` = `pets`.`pet_id` WHERE `toys`.`name` = ? [["name", "Bone"]] ```
Diffstat (limited to 'activerecord/lib/arel/visitors/mysql.rb')
-rw-r--r--activerecord/lib/arel/visitors/mysql.rb9
1 files changed, 1 insertions, 8 deletions
diff --git a/activerecord/lib/arel/visitors/mysql.rb b/activerecord/lib/arel/visitors/mysql.rb
index 9d9294fecc..5d10088427 100644
--- a/activerecord/lib/arel/visitors/mysql.rb
+++ b/activerecord/lib/arel/visitors/mysql.rb
@@ -75,14 +75,7 @@ module Arel # :nodoc: all
o
end
end
-
- def prepare_delete_statement(o)
- if o.offset || has_join_sources?(o)
- super
- else
- o
- end
- end
+ alias :prepare_delete_statement :prepare_update_statement
# MySQL is too stupid to create a temporary table for use subquery, so we have
# to give it some prompting in the form of a subsubquery.