summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGreg Stark <stark@gitlab.com>2018-02-12 14:44:58 +0100
committerGreg Stark <stark@gitlab.com>2018-02-15 00:57:26 +0100
commit629cc37217bb2e41da69fe2304f343189a10e710 (patch)
treeea6244ba7357a4420b2e6ce91f9e368ef22e42a3
parent5ca692b0b04b4f349fb5a08b9dcc7d87c774934e (diff)
downloadgitlab-ce-index-for-groups-analytic-controller-4899.tar.gz
Add index on events table on project_id, created_at to support Group::AnalyticsControllerindex-for-groups-analytic-controller-4899
-rw-r--r--changelogs/unreleased/index-for-groups-analytic-controller-4899.yml5
-rw-r--r--db/migrate/20180212121259_index_for_groups_analytic_controller_4899.rb18
-rw-r--r--db/schema.rb3
3 files changed, 25 insertions, 1 deletions
diff --git a/changelogs/unreleased/index-for-groups-analytic-controller-4899.yml b/changelogs/unreleased/index-for-groups-analytic-controller-4899.yml
new file mode 100644
index 00000000000..5ea3f3b19e8
--- /dev/null
+++ b/changelogs/unreleased/index-for-groups-analytic-controller-4899.yml
@@ -0,0 +1,5 @@
+---
+title: Add index on events table on project_id, created_at to support Group::AnalyticsController
+merge_request:
+author:
+type: performance
diff --git a/db/migrate/20180212121259_index_for_groups_analytic_controller_4899.rb b/db/migrate/20180212121259_index_for_groups_analytic_controller_4899.rb
new file mode 100644
index 00000000000..d57d5a1ce79
--- /dev/null
+++ b/db/migrate/20180212121259_index_for_groups_analytic_controller_4899.rb
@@ -0,0 +1,18 @@
+# See http://doc.gitlab.com/ce/development/migration_style_guide.html
+# for more information on how to write migrations for GitLab.
+
+class IndexForGroupsAnalyticController4899 < ActiveRecord::Migration
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :events, [:project_id, :created_at]
+ end
+
+ def down
+ remove_concurrent_index :events, [:project_id, :created_at]
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 6b43fc8403c..4b4428d3dd4 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 20180208183958) do
+ActiveRecord::Schema.define(version: 20180212121259) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -694,6 +694,7 @@ ActiveRecord::Schema.define(version: 20180208183958) do
add_index "events", ["action"], name: "index_events_on_action", using: :btree
add_index "events", ["author_id"], name: "index_events_on_author_id", using: :btree
+ add_index "events", ["project_id", "created_at"], name: "index_events_on_project_id_and_created_at", using: :btree
add_index "events", ["project_id", "id"], name: "index_events_on_project_id_and_id", using: :btree
add_index "events", ["target_type", "target_id"], name: "index_events_on_target_type_and_target_id", using: :btree