]> git.openstreetmap.org Git - rails.git/commitdiff
add note table user_id, created_at index for non-anonymus notes
authorEmin Kocan <kocanmn.dev@gmail.com>
Fri, 7 Mar 2025 04:07:54 +0000 (05:07 +0100)
committerEmin Kocan <kocanmn.dev@gmail.com>
Fri, 7 Mar 2025 04:07:54 +0000 (05:07 +0100)
app/models/note.rb
db/migrate/20250304172798_add_notes_user_id_created_at_index.rb [new file with mode: 0644]
db/structure.sql

index 068efa59a3c35c39c920e1d92882822963bde444..6a83b6b0117dabc49917fa38e045f3893ea96b76 100644 (file)
 #
 # Indexes
 #
-#  index_notes_on_description  (to_tsvector('english'::regconfig, description)) USING gin
-#  notes_created_at_idx        (created_at)
-#  notes_tile_status_idx       (tile,status)
-#  notes_updated_at_idx        (updated_at)
+#  index_notes_on_description             (to_tsvector('english'::regconfig, description)) USING gin
+#  index_notes_on_user_id_and_created_at  (user_id,created_at) WHERE (user_id IS NOT NULL)
+#  notes_created_at_idx                   (created_at)
+#  notes_tile_status_idx                  (tile,status)
+#  notes_updated_at_idx                   (updated_at)
 #
 # Foreign Keys
 #
diff --git a/db/migrate/20250304172798_add_notes_user_id_created_at_index.rb b/db/migrate/20250304172798_add_notes_user_id_created_at_index.rb
new file mode 100644 (file)
index 0000000..52ee20f
--- /dev/null
@@ -0,0 +1,9 @@
+class AddNotesUserIdCreatedAtIndex < ActiveRecord::Migration[7.2]
+  disable_ddl_transaction!
+
+  def change
+    add_index :notes, [:user_id, :created_at],
+              :algorithm => :concurrently,
+              :where => "user_id IS NOT NULL"
+  end
+end
index 7f44938b377d5ae92d25deea21d13992b7e77288..9d3af4d001979914fd03e0f051750c40ef8c7070 100644 (file)
@@ -9,6 +9,7 @@ SET xmloption = content;
 SET client_min_messages = warning;
 SET row_security = off;
 
+
 --
 -- Name: btree_gist; Type: EXTENSION; Schema: -; Owner: -
 --
@@ -2554,6 +2555,13 @@ CREATE INDEX index_note_subscriptions_on_note_id ON public.note_subscriptions US
 CREATE INDEX index_notes_on_description ON public.notes USING gin (to_tsvector('english'::regconfig, description));
 
 
+--
+-- Name: index_notes_on_user_id_and_created_at; Type: INDEX; Schema: public; Owner: -
+--
+
+CREATE INDEX index_notes_on_user_id_and_created_at ON public.notes USING btree (user_id, created_at) WHERE (user_id IS NOT NULL);
+
+
 --
 -- Name: index_oauth_access_grants_on_application_id; Type: INDEX; Schema: public; Owner: -
 --
@@ -3436,6 +3444,7 @@ INSERT INTO "schema_migrations" (version) VALUES
 ('23'),
 ('22'),
 ('21'),
+('20250304172798'),
 ('20250304172758'),
 ('20250212160355'),
 ('20250206202905'),