PgHero
No long running queries
Connections healthy 34
Vacuuming healthy
No columns near integer overflow (41 unreadable sequences)
No invalid indexes or constraints
74 duplicate indexes
Query stats must be enabled for slow queries

Duplicate Indexes

These indexes exist, but aren’t needed. Remove them for faster writes.

rails generate migration remove_unneeded_indexes

And paste

remove_index :account_group_memberships, name: "account_group_memberships_accountId_idx", column: :platform_account_id
remove_index :active_timer, name: "active_timer_staff_id_idx", column: :staff_id
remove_index :active_timer, name: "active_timer_staff_id_idx", column: :staff_id
remove_index :appointment, name: "appointment_public_booking_token_idx", column: :public_booking_token
remove_index :appointment, name: "appointment_public_booking_token_idx", column: :public_booking_token
remove_index :appointment_type, name: "appointment_type_public_booking_token_idx", column: :public_booking_token
remove_index :appointment_type, name: "appointment_type_public_booking_token_idx", column: :public_booking_token
remove_index :appraisal_cycles, name: "appraisal_cycles_departmentid_idx", column: :department_id
remove_index :appraisal_followups, name: "appraisal_followups_appraisalid_idx", column: :appraisal_id
remove_index :appraisals, name: "appraisals_scheduleddate_idx", column: :scheduled_date
remove_index :appraisals, name: "appraisals_staffprofileid_idx", column: :staff_profile_id
remove_index :attendance_exceptions, name: "attendance_exceptions_staffprofileid_idx", column: :staff_profile_id
remove_index :career_path_years, name: "career_path_years_planid_idx", column: :career_path_plan_id
remove_index :cash_reconciliation_rule, name: "idx_cash_recon_rule_org", column: :organization_id
remove_index :combo_product, name: "idx_combo_product_product", column: :product_id
remove_index :customer, name: "idx_customer_org", column: :organization_id
remove_index :customer_pricelist, name: "idx_customer_pricelist_cust", column: :customer_id
remove_index :customer_to_tag, name: "customerToTag_customerId_idx", column: :customer_id
remove_index :cycle_work_items, name: "cycle_work_items_cycleId_idx", column: :cycle_id
remove_index :department_assignments, name: "department_assignments_staffprofileid_idx", column: :staff_profile_id
remove_index :email_report_preference, name: "email_report_preference_userId_idx", column: :user_id
remove_index :expense, name: "idx_expense_org", column: :organization_id
remove_index :expense_category, name: "idx_expense_category_org", column: :organization_id
remove_index :expense_category_link, name: "idx_ecl_expense", column: :expense_id
remove_index :friendships, name: "friendships_requester_idx", column: :requester_id
remove_index :funding_source, name: "idx_funding_source_org", column: :organization_id
remove_index :gift_card, name: "idx_gift_card_code", column: :code
remove_index :invoice, name: "invoice_invoice_number_idx", column: :invoice_number
remove_index :invoice, name: "invoice_invoice_number_idx", column: :invoice_number
remove_index :matter, name: "matter_reference_number_idx", column: :reference_number
remove_index :matter, name: "matter_reference_number_idx", column: :reference_number
remove_index :member, name: "member_userId_idx", column: :user_id
remove_index :notification, name: "notification_userId_idx", column: :user_id
remove_index :notification_preference, name: "notification_preference_user_id_idx", column: :user_id
remove_index :notification_preference, name: "notification_preference_user_id_idx", column: :user_id
remove_index :on_call_schedules, name: "schedules_weekStart_idx", column: :week_start
remove_index :organization, name: "organization_slug_idx", column: :slug
remove_index :passkey, name: "passkey_credentialId_idx", column: :credential_id
remove_index :platform_accounts, name: "platform_accounts_platform_idx", column: :platform
remove_index :portal_document_upload, name: "portal_document_upload_document_id_idx", column: :document_id
remove_index :portal_document_upload, name: "portal_document_upload_document_id_idx", column: :document_id
remove_index :portal_invite, name: "portal_invite_token_idx", column: :token
remove_index :portal_invite, name: "portal_invite_token_idx", column: :token
remove_index :portal_password_reset, name: "portal_password_reset_token_idx", column: :token
remove_index :portal_password_reset, name: "portal_password_reset_token_idx", column: :token
remove_index :portal_session, name: "portal_session_token_idx", column: :token
remove_index :portal_session, name: "portal_session_token_idx", column: :token
remove_index :portal_user, name: "portal_user_client_id_idx", column: :client_id
remove_index :portal_user, name: "portal_user_client_id_idx", column: :client_id
remove_index :portal_user, name: "portal_user_email_idx", column: :email
remove_index :portal_user, name: "portal_user_email_idx", column: :email
remove_index :ppe_issuances, name: "ppe_issuances_staffprofileid_idx", column: :staff_profile_id
remove_index :pricelist_item, name: "idx_pricelist_item_list", column: :pricelist_id
remove_index :push_subscription, name: "push_subscription_userId_idx", column: :user_id
remove_index :receipt_config, name: "idx_receipt_config_org", column: :organization_id
remove_index :report_definition, name: "report_definition_report_code_idx", column: :report_code
remove_index :report_definition, name: "report_definition_report_code_idx", column: :report_code
remove_index :roster_assignments, name: "roster_assignments_scheduleid_idx", column: :schedule_id
remove_index :session, name: "session_token_idx", column: :token
remove_index :staff, name: "staff_user_id_idx", column: :user_id
remove_index :staff, name: "staff_user_id_idx", column: :user_id
remove_index :staff_impersonation_session, name: "staff_impersonation_session_token_idx", column: :token
remove_index :staff_impersonation_session, name: "staff_impersonation_session_token_idx", column: :token
remove_index :staff_invite, name: "staff_invite_token_idx", column: :token
remove_index :staff_invite, name: "staff_invite_token_idx", column: :token
remove_index :staff_profiles, name: "staff_profiles_userId_idx", column: :user_id
remove_index :submission_reactions, name: "submission_reactions_sub_idx", column: :submission_id
remove_index :tag, name: "tag_name_idx", column: :name
remove_index :tag, name: "tag_name_idx", column: :name
remove_index :timesheets, name: "timesheets_staffprofileid_idx", column: :staff_profile_id
remove_index :user_role, name: "idx_user_role_user", column: :user_id
remove_index :work_item_assignees, name: "work_item_assignees_work_item_idx", column: :work_item_id
remove_index :work_item_dependencies, name: "work_item_deps_workItemId_idx", column: :work_item_id
remove_index :work_item_team_allocations, name: "work_item_team_alloc_work_item_idx", column: :work_item_id
Details
On account_group_memberships
account_group_memberships_accountId_idx (platform_account_id)
is covered by
account_group_memberships_unique (platform_account_id, access_group_id)
On active_timer
active_timer_staff_id_idx (staff_id)
is covered by
active_timer_staff_id_unique (staff_id)
On active_timer
active_timer_staff_id_idx (staff_id)
is covered by
active_timer_staff_id_unique (staff_id)
On appointment
appointment_public_booking_token_idx (public_booking_token)
is covered by
appointment_public_booking_token_unique (public_booking_token)
On appointment
appointment_public_booking_token_idx (public_booking_token)
is covered by
appointment_public_booking_token_unique (public_booking_token)
On appointment_type
appointment_type_public_booking_token_idx (public_booking_token)
is covered by
appointment_type_public_booking_token_unique (public_booking_token)
On appointment_type
appointment_type_public_booking_token_idx (public_booking_token)
is covered by
appointment_type_public_booking_token_unique (public_booking_token)
On appraisal_cycles
appraisal_cycles_departmentid_idx (department_id)
is covered by
appraisal_cycles_department_year_half_unique (department_id, year, half)
On appraisal_followups
appraisal_followups_appraisalid_idx (appraisal_id)
is covered by
appraisal_followups_appraisal_followup_type_unique (appraisal_id, follow_up_type)
On appraisals
appraisals_scheduleddate_idx (scheduled_date)
is covered by
appraisals_scheduledDate_idx (scheduled_date)
On appraisals
appraisals_staffprofileid_idx (staff_profile_id)
is covered by
appraisals_staffProfileId_idx (staff_profile_id)
On attendance_exceptions
attendance_exceptions_staffprofileid_idx (staff_profile_id)
is covered by
attendance_exceptions_staff_date_idx (staff_profile_id, exception_date)
On career_path_years
career_path_years_planid_idx (career_path_plan_id)
is covered by
career_path_years_plan_year_unique (career_path_plan_id, year_number)
On cash_reconciliation_rule
idx_cash_recon_rule_org (organization_id)
is covered by
cash_reconciliation_rule_organization_id_unique (organization_id)
On combo_product
idx_combo_product_product (product_id)
is covered by
combo_product_product_id_unique (product_id)
On customer
idx_customer_org (organization_id)
is covered by
idx_customer_org_phone (organization_id, phone)
On customer_pricelist
idx_customer_pricelist_cust (customer_id)
is covered by
idx_customer_pricelist_uniq (customer_id, pricelist_id)
On customer_to_tag
customerToTag_customerId_idx (customer_id)
is covered by
customer_to_tag_customer_id_tag_id_pk (customer_id, tag_id)
On cycle_work_items
cycle_work_items_cycleId_idx (cycle_id)
is covered by
cycle_work_items_unique (cycle_id, work_item_id)
On department_assignments
department_assignments_staffprofileid_idx (staff_profile_id)
is covered by
department_assignments_staff_department_role_unique (staff_profile_id, department_id, role)
On email_report_preference
email_report_preference_userId_idx (user_id)
is covered by
email_report_preference_userId_organizationId_idx (user_id, organization_id)
On expense
idx_expense_org (organization_id)
is covered by
idx_expense_billable_uninvoiced (organization_id, billable, invoiced_at)
On expense_category
idx_expense_category_org (organization_id)
is covered by
expense_category_org_name (organization_id, name)
On expense_category_link
idx_ecl_expense (expense_id)
is covered by
expense_category_link_pkey (expense_id, category_id)
On friendships
friendships_requester_idx (requester_id)
is covered by
friendships_requester_id_addressee_id_key (requester_id, addressee_id)
On funding_source
idx_funding_source_org (organization_id)
is covered by
funding_source_organization_id_name_key (organization_id, name)
On gift_card
idx_gift_card_code (code)
is covered by
gift_card_code_unique (code)
On invoice
invoice_invoice_number_idx (invoice_number)
is covered by
invoice_invoice_number_unique (invoice_number)
On invoice
invoice_invoice_number_idx (invoice_number)
is covered by
invoice_invoice_number_unique (invoice_number)
On matter
matter_reference_number_idx (reference_number)
is covered by
matter_reference_number_unique (reference_number)
On matter
matter_reference_number_idx (reference_number)
is covered by
matter_reference_number_unique (reference_number)
On member
member_userId_idx (user_id)
is covered by
member_userId_organizationId_idx (user_id, organization_id)
On notification
notification_userId_idx (user_id)
is covered by
notification_userId_isRead_idx (user_id, is_read)
On notification_preference
notification_preference_user_id_idx (user_id)
is covered by
notification_preference_user_id_unique (user_id)
On notification_preference
notification_preference_user_id_idx (user_id)
is covered by
notification_preference_user_id_unique (user_id)
On on_call_schedules
schedules_weekStart_idx (week_start)
is covered by
on_call_schedules_week_start_unique (week_start)
On organization
organization_slug_idx (slug)
is covered by
organization_slug_unique (slug)
On passkey
passkey_credentialId_idx (credential_id)
is covered by
passkey_credential_id_unique (credential_id)
On platform_accounts
platform_accounts_platform_idx (platform)
is covered by
platform_accounts_platform_identifier_unique (platform, account_identifier)
On portal_document_upload
portal_document_upload_document_id_idx (document_id)
is covered by
portal_document_upload_document_id_unique (document_id)
On portal_document_upload
portal_document_upload_document_id_idx (document_id)
is covered by
portal_document_upload_document_id_unique (document_id)
On portal_invite
portal_invite_token_idx (token)
is covered by
portal_invite_token_unique (token)
On portal_invite
portal_invite_token_idx (token)
is covered by
portal_invite_token_unique (token)
On portal_password_reset
portal_password_reset_token_idx (token)
is covered by
portal_password_reset_token_unique (token)
On portal_password_reset
portal_password_reset_token_idx (token)
is covered by
portal_password_reset_token_unique (token)
On portal_session
portal_session_token_idx (token)
is covered by
portal_session_token_unique (token)
On portal_session
portal_session_token_idx (token)
is covered by
portal_session_token_unique (token)
On portal_user
portal_user_client_id_idx (client_id)
is covered by
portal_user_client_id_unique (client_id)
On portal_user
portal_user_client_id_idx (client_id)
is covered by
portal_user_client_id_unique (client_id)
On portal_user
portal_user_email_idx (email)
is covered by
portal_user_email_unique (email)
On portal_user
portal_user_email_idx (email)
is covered by
portal_user_email_unique (email)
On ppe_issuances
ppe_issuances_staffprofileid_idx (staff_profile_id)
is covered by
ppe_issuances_staff_item_unique (staff_profile_id, ppe_item_id)
On pricelist_item
idx_pricelist_item_list (pricelist_id)
is covered by
idx_pricelist_item_uniq (pricelist_id, product_id)
On push_subscription
push_subscription_userId_idx (user_id)
is covered by
push_subscription_userId_endpoint_unique (user_id, endpoint)
On receipt_config
idx_receipt_config_org (organization_id)
is covered by
receipt_config_organization_id_unique (organization_id)
On report_definition
report_definition_report_code_idx (report_code)
is covered by
report_definition_report_code_unique (report_code)
On report_definition
report_definition_report_code_idx (report_code)
is covered by
report_definition_report_code_unique (report_code)
On roster_assignments
roster_assignments_scheduleid_idx (schedule_id)
is covered by
roster_assignments_schedule_staff_date_type_unique (schedule_id, staff_profile_id, shift_date, shift_type)
On session
session_token_idx (token)
is covered by
session_token_key (token)
On staff
staff_user_id_idx (user_id)
is covered by
staff_user_id_unique (user_id)
On staff
staff_user_id_idx (user_id)
is covered by
staff_user_id_unique (user_id)
On staff_impersonation_session
staff_impersonation_session_token_idx (token)
is covered by
staff_impersonation_session_token_unique (token)
On staff_impersonation_session
staff_impersonation_session_token_idx (token)
is covered by
staff_impersonation_session_token_unique (token)
On staff_invite
staff_invite_token_idx (token)
is covered by
staff_invite_token_unique (token)
On staff_invite
staff_invite_token_idx (token)
is covered by
staff_invite_token_unique (token)
On staff_profiles
staff_profiles_userId_idx (user_id)
is covered by
staff_profiles_user_id_unique (user_id)
On submission_reactions
submission_reactions_sub_idx (submission_id)
is covered by
submission_reactions_submission_id_user_id_type_key (submission_id, user_id, type)
On tag
tag_name_idx (name)
is covered by
tag_name_unique (name)
On tag
tag_name_idx (name)
is covered by
tag_name_unique (name)
On timesheets
timesheets_staffprofileid_idx (staff_profile_id)
is covered by
timesheets_staff_period_unique (staff_profile_id, period_start, period_end)
On user_role
idx_user_role_user (user_id)
is covered by
user_role_user_id_role_id_pk (user_id, role_id)
On work_item_assignees
work_item_assignees_work_item_idx (work_item_id)
is covered by
work_item_assignees_unique (work_item_id, staff_profile_id)
On work_item_dependencies
work_item_deps_workItemId_idx (work_item_id)
is covered by
work_item_deps_unique (work_item_id, depends_on_id)
On work_item_team_allocations
work_item_team_alloc_work_item_idx (work_item_id)
is covered by
work_item_team_alloc_unique (work_item_id, department_id)

Query Stats

Make them available by adding the following lines to postgresql.conf:

shared_preload_libraries = 'pg_stat_statements'
pg_stat_statements.track = all

Restart the server for the changes to take effect.