From c299e26e6740cb32493700fa125bcb746951940c Mon Sep 17 00:00:00 2001 From: Fox Ellson-Taylor Date: Mon, 25 Aug 2025 08:01:05 -0500 Subject: [PATCH] improve machine and ip address heartbeat querying speeds (#490) --- db/migrate/20250821021751_add_alt_identifying_indexes.rb | 6 ++++++ db/schema.rb | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20250821021751_add_alt_identifying_indexes.rb diff --git a/db/migrate/20250821021751_add_alt_identifying_indexes.rb b/db/migrate/20250821021751_add_alt_identifying_indexes.rb new file mode 100644 index 0000000..ad9a549 --- /dev/null +++ b/db/migrate/20250821021751_add_alt_identifying_indexes.rb @@ -0,0 +1,6 @@ +class AddAltIdentifyingIndexes < ActiveRecord::Migration[8.0] + def change + add_index :heartbeats, :ip_address + add_index :heartbeats, :machine + end +end diff --git a/db/schema.rb b/db/schema.rb index 61d5f61..db9627d 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[8.0].define(version: 2025_07_22_233948) do +ActiveRecord::Schema[8.0].define(version: 2025_08_21_021751) do create_schema "pganalyze" # These are extensions that must be enabled in order to support this database @@ -258,6 +258,8 @@ ActiveRecord::Schema[8.0].define(version: 2025_07_22_233948) do t.bigint "raw_heartbeat_upload_id" t.index ["category", "time"], name: "index_heartbeats_on_category_and_time" t.index ["fields_hash"], name: "index_heartbeats_on_fields_hash_when_not_deleted", unique: true, where: "(deleted_at IS NULL)" + t.index ["ip_address"], name: "index_heartbeats_on_ip_address" + t.index ["machine"], name: "index_heartbeats_on_machine" t.index ["project", "time"], name: "index_heartbeats_on_project_and_time" t.index ["project"], name: "index_heartbeats_on_project" t.index ["raw_heartbeat_upload_id"], name: "index_heartbeats_on_raw_heartbeat_upload_id"