diff --git a/changelogs/unreleased/optimize-note-indexes.yml b/changelogs/unreleased/optimize-note-indexes.yml
new file mode 100644
index 0000000000000000000000000000000000000000..bfb84779abf0fa1d2df0ee1f98c9a99325ef78e0
--- /dev/null
+++ b/changelogs/unreleased/optimize-note-indexes.yml
@@ -0,0 +1,5 @@
+---
+title: Optimize DB indexes for ES indexing of notes
+merge_request: 31846
+author:
+type: performance
diff --git a/db/migrate/20190815093936_add_index_notes_on_project_id_and_id_and_system_false.rb b/db/migrate/20190815093936_add_index_notes_on_project_id_and_id_and_system_false.rb
new file mode 100644
index 0000000000000000000000000000000000000000..cbbece35901d3c79ee45e27091891eab136ae9d8
--- /dev/null
+++ b/db/migrate/20190815093936_add_index_notes_on_project_id_and_id_and_system_false.rb
@@ -0,0 +1,30 @@
+# frozen_string_literal: true
+
+class AddIndexNotesOnProjectIdAndIdAndSystemFalse < ActiveRecord::Migration[5.2]
+  include Gitlab::Database::MigrationHelpers
+
+  DOWNTIME = false
+
+  disable_ddl_transaction!
+
+  def up
+    add_concurrent_index(*index_arguments)
+  end
+
+  def down
+    remove_concurrent_index(*index_arguments)
+  end
+
+  private
+
+  def index_arguments
+    [
+      :notes,
+      [:project_id, :id],
+      {
+        name: 'index_notes_on_project_id_and_id_and_system_false',
+        where: 'NOT system'
+      }
+    ]
+  end
+end
diff --git a/db/migrate/20190815093949_remove_index_notes_on_noteable_type.rb b/db/migrate/20190815093949_remove_index_notes_on_noteable_type.rb
new file mode 100644
index 0000000000000000000000000000000000000000..158c88e625860400025ee20c73e3d14d442e3841
--- /dev/null
+++ b/db/migrate/20190815093949_remove_index_notes_on_noteable_type.rb
@@ -0,0 +1,29 @@
+# frozen_string_literal: true
+
+class RemoveIndexNotesOnNoteableType < ActiveRecord::Migration[5.2]
+  include Gitlab::Database::MigrationHelpers
+
+  DOWNTIME = false
+
+  disable_ddl_transaction!
+
+  def up
+    remove_concurrent_index(*index_arguments)
+  end
+
+  def down
+    add_concurrent_index(*index_arguments)
+  end
+
+  private
+
+  def index_arguments
+    [
+      :notes,
+      [:noteable_type],
+      {
+        name: 'index_notes_on_noteable_type'
+      }
+    ]
+  end
+end
diff --git a/db/schema.rb b/db/schema.rb
index cf7f0fc0a3d57cb78dadeb91e0af3e1b2f47ebfe..fafaec3fb51c7085ebf56c96a5fa9ee9f3dd25ff 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -10,7 +10,7 @@
 #
 # It's strongly recommended that you check this file into your version control system.
 
-ActiveRecord::Schema.define(version: 2019_08_12_070645) do
+ActiveRecord::Schema.define(version: 2019_08_15_093949) do
 
   # These are extensions that must be enabled in order to support this database
   enable_extension "pg_trgm"
@@ -2279,7 +2279,7 @@
     t.index ["line_code"], name: "index_notes_on_line_code"
     t.index ["note"], name: "index_notes_on_note_trigram", opclass: :gin_trgm_ops, using: :gin
     t.index ["noteable_id", "noteable_type"], name: "index_notes_on_noteable_id_and_noteable_type"
-    t.index ["noteable_type"], name: "index_notes_on_noteable_type"
+    t.index ["project_id", "id"], name: "index_notes_on_project_id_and_id_and_system_false", where: "(NOT system)"
     t.index ["project_id", "noteable_type"], name: "index_notes_on_project_id_and_noteable_type"
     t.index ["review_id"], name: "index_notes_on_review_id"
   end