From 7db05e5092dad722f73c10d17074f0084be49fb6 Mon Sep 17 00:00:00 2001 From: Alexa Grey Date: Fri, 6 Dec 2024 09:59:18 -0800 Subject: [PATCH] [C] Remove unused indices These indices are huge and not getting used by the query planner. --- ...remove_unused_text_section_node_indices.rb | 17 +++++++++++++ api/db/structure.sql | 24 ++----------------- 2 files changed, 19 insertions(+), 22 deletions(-) create mode 100644 api/db/migrate/20241206175512_remove_unused_text_section_node_indices.rb diff --git a/api/db/migrate/20241206175512_remove_unused_text_section_node_indices.rb b/api/db/migrate/20241206175512_remove_unused_text_section_node_indices.rb new file mode 100644 index 0000000000..d956545e90 --- /dev/null +++ b/api/db/migrate/20241206175512_remove_unused_text_section_node_indices.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +class RemoveUnusedTextSectionNodeIndices < ActiveRecord::Migration[6.1] + def up + execute <<~SQL + DROP INDEX IF EXISTS index_text_section_nodes_pairing; + + DROP INDEX IF EXISTS index_text_section_nodes_on_node_path; + + DROP INDEX IF EXISTS index_text_section_nodes_by_id_and_hash; + SQL + end + + def down + # Intentionally left blank. We won't add these indices back. + end +end diff --git a/api/db/structure.sql b/api/db/structure.sql index ac80d3bb7f..51370ead1a 100644 --- a/api/db/structure.sql +++ b/api/db/structure.sql @@ -5576,13 +5576,6 @@ CREATE UNIQUE INDEX index_text_exports_uniqueness ON public.text_exports USING b CREATE INDEX index_text_section_nodes_actual_ancestors ON public.text_section_nodes USING gist (node_path) WHERE (NOT intermediate); --- --- Name: index_text_section_nodes_by_id_and_hash; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX index_text_section_nodes_by_id_and_hash ON public.text_section_nodes USING btree (text_section_id, body_hash); - - -- -- Name: index_text_section_nodes_by_uuid; Type: INDEX; Schema: public; Owner: - -- @@ -5604,13 +5597,6 @@ CREATE INDEX index_text_section_nodes_child_ordering ON public.text_section_node CREATE INDEX index_text_section_nodes_extrapolation ON public.text_section_nodes USING btree (text_section_id, extrapolated_at); --- --- Name: index_text_section_nodes_on_node_path; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX index_text_section_nodes_on_node_path ON public.text_section_nodes USING gist (node_path); - - -- -- Name: index_text_section_nodes_on_text_section_id; Type: INDEX; Schema: public; Owner: - -- @@ -5618,13 +5604,6 @@ CREATE INDEX index_text_section_nodes_on_node_path ON public.text_section_nodes CREATE INDEX index_text_section_nodes_on_text_section_id ON public.text_section_nodes USING btree (text_section_id); --- --- Name: index_text_section_nodes_pairing; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX index_text_section_nodes_pairing ON public.text_section_nodes USING btree (node_path) INCLUDE (path); - - -- -- Name: index_text_section_nodes_uniqueness; Type: INDEX; Schema: public; Owner: - -- @@ -7194,6 +7173,7 @@ INSERT INTO "schema_migrations" (version) VALUES ('20231129172116'), ('20240220212417'), ('20240223163849'), -('20240327194259'); +('20240327194259'), +('20241206175512');