Skip to content
Browse files

Added migrations with indexes that make most screens straight index l…

…ookups. Should considerably improve opinions responsiveness.
  • Loading branch information...
1 parent 1660304 commit 8821fd44a80e0fa6c9fb5c8e357acae980ff5d1e @tobi committed Sep 7, 2009
Showing with 33 additions and 7 deletions.
  1. +19 −0 db/migrate/20090907173425_add_sane_indexes.rb
  2. +14 −7 db/schema.rb
View
19 db/migrate/20090907173425_add_sane_indexes.rb
@@ -0,0 +1,19 @@
+class AddSaneIndexes < ActiveRecord::Migration
+ def self.up
+ add_index :users, :email
+
+ add_index :categories, :access_level
+
+ add_index :posts, [:parent_id, :type]
+ add_index :posts, :created_at
+ add_index :posts, [:category_id, :type]
+ end
+
+ def self.down
+ remove_index :posts, [:parent_id, :type]
+ remove_index :posts, :created_at
+ remove_index :categories, :access_level
+ remove_index :users, :email
+ remove_index :posts, [:category_id, :type]
+ end
+end
View
21 db/schema.rb
@@ -9,23 +9,24 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 33) do
+ActiveRecord::Schema.define(:version => 20090907173425) do
create_table "categories", :force => true do |t|
t.string "title"
t.integer "forum_id"
- t.text "body", :limit => 255
- t.text "body_html", :limit => 255
+ t.text "body"
+ t.text "body_html"
t.string "subtitle"
- t.integer "access_level", :default => 0
+ t.integer "access_level", :default => 0
end
+ add_index "categories", ["access_level"], :name => "index_categories_on_access_level"
add_index "categories", ["forum_id"], :name => "index_categories_on_area_id_and_title_dashed"
create_table "forums", :force => true do |t|
t.string "title"
- t.boolean "anonymous_posts", :default => false
- t.text "body", :limit => 255
+ t.boolean "anonymous_posts", :default => false
+ t.text "body"
end
create_table "images", :force => true do |t|
@@ -57,6 +58,10 @@
t.datetime "edited_at"
end
+ add_index "posts", ["category_id", "type"], :name => "index_posts_on_category_id_and_type"
+ add_index "posts", ["created_at"], :name => "index_posts_on_created_at"
+ add_index "posts", ["parent_id", "type"], :name => "index_posts_on_parent_id_and_type"
+
create_table "users", :force => true do |t|
t.string "password"
t.string "name"
@@ -65,7 +70,9 @@
t.integer "level"
t.string "token", :limit => 32
t.string "title"
- t.text "signature", :limit => 255
+ t.text "signature"
end
+ add_index "users", ["email"], :name => "index_users_on_email"
+
end

0 comments on commit 8821fd4

Please sign in to comment.
Something went wrong with that request. Please try again.