From d428e2c7fcaa49bfe18e720fa76b8e5e58e807c5 Mon Sep 17 00:00:00 2001 From: Ian Littman Date: Thu, 15 Jan 2026 12:56:01 -0600 Subject: [PATCH] Drop attempt number from index to avoid extra write overhead (#38391) Found in connection with #35916. No changes file as this is effectively an unreleased bugfix (will cherry-pick this). No updates to tests because tests don't test index existence. - [x] Input data is properly validated, `SELECT *` is avoided, SQL injection is prevented (using placeholders for values in statements) --- ...0109231821_AddAttemptNumberToScriptsAndSoftwareInstalls.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/datastore/mysql/migrations/tables/20260109231821_AddAttemptNumberToScriptsAndSoftwareInstalls.go b/server/datastore/mysql/migrations/tables/20260109231821_AddAttemptNumberToScriptsAndSoftwareInstalls.go index 715f4f81a4..f7bb63485f 100644 --- a/server/datastore/mysql/migrations/tables/20260109231821_AddAttemptNumberToScriptsAndSoftwareInstalls.go +++ b/server/datastore/mysql/migrations/tables/20260109231821_AddAttemptNumberToScriptsAndSoftwareInstalls.go @@ -28,14 +28,14 @@ func Up_20260109231821(tx *sql.Tx) error { _, err = tx.Exec(` ALTER TABLE host_script_results - ADD INDEX idx_host_script_results_host_policy_attempt (host_id, policy_id, attempt_number); + ADD INDEX idx_host_script_results_host_policy (host_id, policy_id); `) if err != nil { return errors.Wrap(err, "adding index to host_script_results") } _, err = tx.Exec(` ALTER TABLE host_software_installs - ADD INDEX idx_host_software_installs_host_policy_attempt (host_id, policy_id, attempt_number); + ADD INDEX idx_host_software_installs_host_policy (host_id, policy_id); `) if err != nil { return errors.Wrap(err, "adding index to host_software_installs")