Add index to commits on user + timestamp

Based on another pg_analyze recommendation
This commit is contained in:
Max Wofford
2025-06-09 10:45:45 -04:00
parent 7c835d7801
commit 62b4b0a9ea
2 changed files with 9 additions and 1 deletions

View File

@@ -0,0 +1,7 @@
class AddIndexToCommitsUserIdCreatedAt < ActiveRecord::Migration[8.0]
disable_ddl_transaction!
def change
add_index :commits, [:user_id, :created_at], algorithm: :concurrently
end
end

3
db/schema.rb generated
View File

@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema[8.0].define(version: 2025_06_09_143856) do
ActiveRecord::Schema[8.0].define(version: 2025_06_09_144356) do
create_schema "pganalyze"
# These are extensions that must be enabled in order to support this database
@@ -79,6 +79,7 @@ ActiveRecord::Schema[8.0].define(version: 2025_06_09_143856) do
t.datetime "updated_at", null: false
t.bigint "repository_id"
t.index ["repository_id"], name: "index_commits_on_repository_id"
t.index ["user_id", "created_at"], name: "index_commits_on_user_id_and_created_at"
t.index ["user_id"], name: "index_commits_on_user_id"
end