indexes on fa url_name / full_name

This commit is contained in:
Dylan Knutson
2025-07-21 19:17:08 +00:00
parent df88a06e88
commit e4d2f7d862
3 changed files with 39 additions and 1 deletions

View File

@@ -1,5 +1,5 @@
<%# nasty hack, otherwise postgres uses a bad query plan %>
<% fav_posts = user.faved_posts.with_user_post_fav.limit(5) %>
<% fav_posts = user.faved_posts.with_user_post_fav.includes(:creator).limit(5) %>
<section class="animated-shadow-sky sky-section">
<h2 class="section-header">
<span class="font-medium text-slate-900">Favorited Posts</span>

View File

@@ -0,0 +1,9 @@
class AddIndexesToDomainUsersFaAuxTable < ActiveRecord::Migration[7.2]
def change
mirai_tablespace!
add_index :domain_users_fa_aux, :url_name
add_index :domain_users_fa_aux, :full_name
add_index :domain_users_fa_aux, :scanned_gallery_at
add_index :domain_users_fa_aux, :scanned_page_at
end
end

View File

@@ -7904,6 +7904,13 @@ CREATE INDEX index_domain_users_e621_aux_on_name ON public.domain_users_e621_aux
CREATE INDEX index_domain_users_fa_aux_on_base_table_id ON public.domain_users_fa_aux USING btree (base_table_id);
--
-- Name: index_domain_users_fa_aux_on_full_name; Type: INDEX; Schema: public; Owner: -; Tablespace: mirai
--
CREATE INDEX index_domain_users_fa_aux_on_full_name ON public.domain_users_fa_aux USING btree (full_name);
--
-- Name: index_domain_users_fa_aux_on_last_gallery_page_id; Type: INDEX; Schema: public; Owner: -; Tablespace: mirai
--
@@ -7918,6 +7925,27 @@ CREATE INDEX index_domain_users_fa_aux_on_last_gallery_page_id ON public.domain_
CREATE INDEX index_domain_users_fa_aux_on_last_user_page_id ON public.domain_users_fa_aux USING btree (last_user_page_id);
--
-- Name: index_domain_users_fa_aux_on_scanned_gallery_at; Type: INDEX; Schema: public; Owner: -; Tablespace: mirai
--
CREATE INDEX index_domain_users_fa_aux_on_scanned_gallery_at ON public.domain_users_fa_aux USING btree (scanned_gallery_at);
--
-- Name: index_domain_users_fa_aux_on_scanned_page_at; Type: INDEX; Schema: public; Owner: -; Tablespace: mirai
--
CREATE INDEX index_domain_users_fa_aux_on_scanned_page_at ON public.domain_users_fa_aux USING btree (scanned_page_at);
--
-- Name: index_domain_users_fa_aux_on_url_name; Type: INDEX; Schema: public; Owner: -; Tablespace: mirai
--
CREATE INDEX index_domain_users_fa_aux_on_url_name ON public.domain_users_fa_aux USING btree (url_name);
--
-- Name: index_domain_users_inkbunny_aux_on_base_table_id; Type: INDEX; Schema: public; Owner: -; Tablespace: mirai
--
@@ -9638,6 +9666,7 @@ ALTER TABLE ONLY public.domain_twitter_tweets
SET search_path TO "$user", public;
INSERT INTO "schema_migrations" (version) VALUES
('20250721172316'),
('20250721171216'),
('20250718220223'),
('20250718195345'),