Bug #1837
closedadd some indexes to improve performance
Description
Today The foreman in my company manages 3500 puppetclasses along with 5 environments.
Doing, a simple search in the puppetclasses controller without indexes by name takes too long! more than 30 seg, as follows:
Completed in 33232ms (View: 68, DB: 33151) | 200 OK [http://puppet.globoi.com/puppetclasses?search=cocoon]
with indexes:
Completed in 92ms (View: 69, DB: 12) | 200 OK [http://puppet.globoi.com/puppetclasses?search=cocoon
Here is the migration created to add some indexes to some columns..
class AddSomeIndexes < ActiveRecord::Migration
def self.up
#environments_puppetclasses
add_index :environments_puppetclasses, :puppetclass_id
add_index :environments_puppetclasses, :environment_id
#puppetclasses
add_index :puppetclasses, :name
#hostgroups_puppetclasses
add_index :hostgroups_puppetclasses, :puppetclass_id
add_index :hostgroups_puppetclasses, :hostgroup_id
end
def self.down
#environments_puppetclasses
remove_index :environments_puppetclasses, :puppetclass_id
remove_index :environments_puppetclasses, :environment_id
#puppetclasses
remove_index :puppetclasses, :name
#hostgroups_puppetclasses
remove_index :hostgroups_puppetclasses, :puppetclass_id
remove_index :hostgroups_puppetclasses, :hostgroup_id
end
end
Updated by Ohad Levy about 12 years ago
- Target version set to 1.1
Great, any chance you would like to send it as a git patch Contribute ? this way you would get the credit :)
Updated by Anonymous about 12 years ago
- Status changed from New to Closed
- % Done changed from 0 to 100
Applied in changeset e1291b41c4252a3002a1e7f5c55c1c8e80a16e0f.