project lookup indexes

This commit is contained in:
Echo
2025-07-08 20:14:02 -04:00
parent 9527cc8a9f
commit 1251503729
2 changed files with 19 additions and 1 deletions

View File

@@ -0,0 +1,15 @@
class AddStatsPerformanceIndexes < ActiveRecord::Migration[8.0]
def change
add_index :heartbeats, [ :user_id, :time, :project ],
name: "idx_heartbeats_user_time_project_stats",
where: "deleted_at IS NULL"
add_index :heartbeats, [ :user_id, :time, :language ],
name: "idx_heartbeats_user_time_language_stats",
where: "deleted_at IS NULL"
add_index :heartbeats, [ :user_id, :project, :time ],
name: "idx_heartbeats_user_project_time_stats",
where: "deleted_at IS NULL AND project IS NOT NULL"
end
end

5
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_07_01_142553) do
ActiveRecord::Schema[8.0].define(version: 2025_07_09_001202) do
create_schema "pganalyze"
# These are extensions that must be enabled in order to support this database
@@ -260,7 +260,10 @@ ActiveRecord::Schema[8.0].define(version: 2025_07_01_142553) do
t.index ["fields_hash"], name: "index_heartbeats_on_fields_hash_when_not_deleted", unique: true, where: "(deleted_at IS NULL)"
t.index ["raw_heartbeat_upload_id"], name: "index_heartbeats_on_raw_heartbeat_upload_id"
t.index ["source_type", "time", "user_id", "project"], name: "index_heartbeats_on_source_type_time_user_project"
t.index ["user_id", "project", "time"], name: "idx_heartbeats_user_project_time_stats", where: "((deleted_at IS NULL) AND (project IS NOT NULL))"
t.index ["user_id", "time", "category"], name: "index_heartbeats_on_user_time_category"
t.index ["user_id", "time", "language"], name: "idx_heartbeats_user_time_language_stats", where: "(deleted_at IS NULL)"
t.index ["user_id", "time", "project"], name: "idx_heartbeats_user_time_project_stats", where: "(deleted_at IS NULL)"
t.index ["user_id", "time"], name: "idx_heartbeats_user_time_active", where: "(deleted_at IS NULL)"
t.index ["user_id"], name: "index_heartbeats_on_user_id"
end