This project is archived and is in readonly mode.
rake db:migrate queries the schema_migrations table many times (unnecessarily?)
Reported by Jeremy Weiskotten | August 25th, 2008 @ 04:59 PM | in 2.x
Here's the log when running "rake db:migrate" when there are 4 migrations in the db/migrate folder (all have already been run).
SQL (0.008272) SELECT version FROM schema_migrations
SQL (0.000360) SELECT version FROM schema_migrations
SQL (0.000286) SELECT version FROM schema_migrations
SQL (0.000271) SELECT version FROM schema_migrations
Migrating to CreateSessions (20080812190111)
SQL (0.000289) SELECT version FROM schema_migrations
Migrating to CreateUsers (20080812190627)
SQL (0.000256) SELECT version FROM schema_migrations
Migrating to AddDefaultUser (20080812205823)
SQL (0.000256) SELECT version FROM schema_migrations
Migrating to AddUsersAdmin (20080813112503)
SQL (0.000266) SELECT version FROM schema_migrations
SQL (0.000309) SELECT version FROM schema_migrations
It appears to be fetching the list of versions once per migration file found in db/migrate, and then some.
This isn't too bad with only a handful of migrations, but older, larger projects with hundreds of migrations can take a while to run, even if you're up to date. The db:migrate task could be smarter and only fetch the versions once at start.
Comments and changes to this ticket
-
Tarmo Tänav August 26th, 2008 @ 03:00 AM
- Tag set to activerecord, migrations
Please test the attached patch
-
Repository August 26th, 2008 @ 06:04 AM
- State changed from new to resolved
- Tag changed from activerecord, migrations to activerecord, migrations, patch
(from [3d2ac918b987ef0cff34f6a7fdd20926b7a9e5d9]) Cache migrated versions list in Migrator and use it to fetch the latest migrated version name [#845 state:resolved]
Also optimized Migrator#current_version class method to fetch only the latest version number and not all of them.
With this change no matter how many migrations there are the schema_migrations table is only SELECTed from once.
Signed-off-by: Jeremy Kemper jeremy@bitsweat.net http://github.com/rails/rails/co...
-
Repository August 26th, 2008 @ 06:04 AM
(from [7d2b72f3ae6f92e61d131349c4580be0d1dd12ca]) Cache migrated versions list in Migrator and use it to fetch the latest migrated version name [#845 state:resolved]
Also optimized Migrator#current_version class method to fetch only the latest version number and not all of them.
With this change no matter how many migrations there are the schema_migrations table is only SELECTed from once.
Signed-off-by: Jeremy Kemper jeremy@bitsweat.net http://github.com/rails/rails/co...
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>
People watching this ticket
Attachments
Tags
Referenced by
- 845 rake db:migrate queries the schema_migrations table many times (unnecessarily?) (from [3d2ac918b987ef0cff34f6a7fdd20926b7a9e5d9]) Cache m...
- 845 rake db:migrate queries the schema_migrations table many times (unnecessarily?) (from [7d2b72f3ae6f92e61d131349c4580be0d1dd12ca]) Cache m...