Project

General

Profile

Actions

Bug #1837

closed

add some indexes to improve performance

Added by Gustavo Soares about 12 years ago. Updated about 12 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
-
Target version:
Difficulty:
Triaged:
Fixed in Releases:
Found in Releases:

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
Actions

Also available in: Atom PDF