aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/models/arunit2_model.rb
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2017-01-05 14:31:32 +0900
committerRyuta Kamizono <kamipo@gmail.com>2017-01-05 14:36:48 +0900
commit801a21e6c9e619297d43d6e4dcec55fb47fd479c (patch)
tree588362b2b7c6e87a6d5b9f457136d445ce1397a8 /activerecord/test/models/arunit2_model.rb
parent46bb76acadc132de0344166db223be5f3fcd5426 (diff)
downloadrails-801a21e6c9e619297d43d6e4dcec55fb47fd479c.tar.gz
rails-801a21e6c9e619297d43d6e4dcec55fb47fd479c.tar.bz2
rails-801a21e6c9e619297d43d6e4dcec55fb47fd479c.zip
Optimizing information_schema query for `foreign_keys`
Need `table_name` to avoid all databases scan. See https://dev.mysql.com/doc/refman/5.7/en/information-schema-optimization.html. ``` > EXPLAIN SELECT fk.referenced_table_name AS 'to_table', fk.referenced_column_name AS 'primary_key', fk.column_name AS 'column', fk.constraint_name AS 'name', rc.update_rule AS 'on_update', rc.delete_rule AS 'on_delete' FROM information_schema.key_column_usage fk JOIN information_schema.referential_constraints rc USING (constraint_schema, constraint_name) WHERE fk.referenced_column_name IS NOT NULL AND fk.table_schema = 'activerecord_unittest' AND fk.table_name = 'fk_test_has_pk' AND rc.table_name = 'fk_test_has_pk'\G *************************** 1. row *************************** id: 1 select_type: SIMPLE table: fk partitions: NULL type: ALL possible_keys: NULL key: TABLE_SCHEMA,TABLE_NAME key_len: NULL ref: NULL rows: NULL filtered: NULL Extra: Using where; Open_full_table; Scanned 0 databases *************************** 2. row *************************** id: 1 select_type: SIMPLE table: rc partitions: NULL type: ALL possible_keys: NULL key: TABLE_NAME key_len: NULL ref: NULL rows: NULL filtered: NULL Extra: Using where; Open_full_table; Scanned 1 database; Using join buffer (Block Nested Loop) 2 rows in set, 1 warning (0.00 sec) ``` Fixes #27579.
Diffstat (limited to 'activerecord/test/models/arunit2_model.rb')
0 files changed, 0 insertions, 0 deletions