mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Don't SELECT * FROM information_schema.tables
Depending on MySQL version and configuration, this is more than two orders of magnitude slower than selecting only the two columns we need for this query, which don't require reading any of the data files or recalculating innodb stats. https://dev.mysql.com/doc/refman/5.6/en/information-schema-optimization.html Performance regression was introduced in #39712, before then the query took around 40-50ms on my test environment, after it took 4-8s. With this change it's back to 40-50ms.
This commit is contained in:
parent
18922cccd4
commit
bccc4c6226
1 changed files with 1 additions and 1 deletions
|
@ -206,7 +206,7 @@ module ActiveRecord
|
|||
def data_source_sql(name = nil, type: nil)
|
||||
scope = quoted_scope(name, type: type)
|
||||
|
||||
sql = +"SELECT table_name FROM (SELECT * FROM information_schema.tables "
|
||||
sql = +"SELECT table_name FROM (SELECT table_name, table_type FROM information_schema.tables "
|
||||
sql << " WHERE table_schema = #{scope[:schema]}) _subquery"
|
||||
if scope[:type] || scope[:name]
|
||||
conditions = []
|
||||
|
|
Loading…
Reference in a new issue