db: add created_at indexes on post_appeals, artist/note/wiki_page versions,

This optimizes queries on /moderator/dashboard that filter by creation date.
This commit is contained in:
evazion 2017-03-18 20:00:13 -05:00
parent d1d0fe9bc5
commit 246eb1e8ab
2 changed files with 39 additions and 0 deletions

View File

@ -0,0 +1,10 @@
class AddCreatedAtIndexToVersions < ActiveRecord::Migration
def change
ActiveRecord::Base.without_timeout do
add_index :note_versions, :created_at
add_index :artist_versions, :created_at
add_index :wiki_page_versions, :created_at
add_index :post_appeals, :created_at
end
end
end

View File

@ -4977,6 +4977,13 @@ CREATE INDEX index_artist_urls_on_url_pattern ON artist_urls USING btree (url te
CREATE INDEX index_artist_versions_on_artist_id ON artist_versions USING btree (artist_id);
--
-- Name: index_artist_versions_on_created_at; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX index_artist_versions_on_created_at ON artist_versions USING btree (created_at);
--
-- Name: index_artist_versions_on_name; Type: INDEX; Schema: public; Owner: -
--
@ -6706,6 +6713,13 @@ CREATE UNIQUE INDEX index_key_values_on_key ON key_values USING btree (key);
CREATE INDEX index_news_updates_on_created_at ON news_updates USING btree (created_at);
--
-- Name: index_note_versions_on_created_at; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX index_note_versions_on_created_at ON note_versions USING btree (created_at);
--
-- Name: index_note_versions_on_note_id; Type: INDEX; Schema: public; Owner: -
--
@ -6790,6 +6804,13 @@ CREATE INDEX index_pools_on_name ON pools USING btree (name);
CREATE INDEX index_pools_on_name_trgm ON pools USING gin (name gin_trgm_ops);
--
-- Name: index_post_appeals_on_created_at; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX index_post_appeals_on_created_at ON post_appeals USING btree (created_at);
--
-- Name: index_post_appeals_on_creator_id; Type: INDEX; Schema: public; Owner: -
--
@ -7147,6 +7168,13 @@ CREATE UNIQUE INDEX index_users_on_name ON users USING btree (lower((name)::text
CREATE INDEX index_users_on_name_trgm ON users USING gin (lower((name)::text) gin_trgm_ops);
--
-- Name: index_wiki_page_versions_on_created_at; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX index_wiki_page_versions_on_created_at ON wiki_page_versions USING btree (created_at);
--
-- Name: index_wiki_page_versions_on_updater_ip_addr; Type: INDEX; Schema: public; Owner: -
--
@ -7532,3 +7560,4 @@ INSERT INTO schema_migrations (version) VALUES ('20170314235626');
INSERT INTO schema_migrations (version) VALUES ('20170316224630');
INSERT INTO schema_migrations (version) VALUES ('20170319000519');