From ccb9b2a0ce1131a1cfc7cef80799cb109a1632b3 Mon Sep 17 00:00:00 2001 From: Yash Mehrotra Date: Mon, 30 Sep 2024 14:59:26 +0530 Subject: [PATCH] chore: add missing indexes --- schema/agents.hcl | 3 +++ schema/config.hcl | 11 +++++++---- schema/playbooks.hcl | 3 +++ schema/system.hcl | 6 ++++++ 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/schema/agents.hcl b/schema/agents.hcl index 3737f31e..9c41d1c4 100644 --- a/schema/agents.hcl +++ b/schema/agents.hcl @@ -98,6 +98,9 @@ table "agents" { columns = [column.name] where = "deleted_at IS NULL" } + index "idx_agents_name" { + columns = [column.name] + } foreign_key "agents_created_by_fkey" { columns = [column.created_by] diff --git a/schema/config.hcl b/schema/config.hcl index 5d352e44..d39440d0 100644 --- a/schema/config.hcl +++ b/schema/config.hcl @@ -196,19 +196,18 @@ table "config_changes" { unique = true columns = [column.config_id, column.external_change_id] } - index "config_changes_change_type_idx" { columns = [column.change_type] } - index "config_changes_config_id_idx" { columns = [column.config_id] } - + index "config_changes_config_id_change_type_idx" { + columns = [column.config_id, column.change_type] + } index "config_changes_fingerprint_idx" { columns = [column.fingerprint] } - index "config_changes_is_pushed_idx" { columns = [column.is_pushed] where = "is_pushed IS FALSE" @@ -390,6 +389,10 @@ table "config_items" { index "idx_config_items_name" { columns = [column.agent_id, column.name, column.type, column.config_class] } + index "idx_config_items_scraper_id_deleted_at_null" { + columns = [column.scraper_id] + where = "deleted_at IS NULL" + } check "config_item_name_type_not_empty" { expr = "LENGTH(name) > 0 AND LENGTH(type) > 0" } diff --git a/schema/playbooks.hcl b/schema/playbooks.hcl index 82bf95ab..23fec3ff 100644 --- a/schema/playbooks.hcl +++ b/schema/playbooks.hcl @@ -347,4 +347,7 @@ table "playbook_run_actions" { index "playbook_run_actions_status_time_idx" { columns = [column.status, column.scheduled_time] } + index "playbook_run_actions_playbook_run_id_idx" { + columns = [column.playbook_run_id] + } } diff --git a/schema/system.hcl b/schema/system.hcl index f19293a0..4af08667 100644 --- a/schema/system.hcl +++ b/schema/system.hcl @@ -220,4 +220,10 @@ table "job_history" { columns = [column.is_pushed] where = "is_pushed IS FALSE AND status in ('FAILED', 'WARNING')" } + index "job_history_resource_id_idx" { + columns = [column.resource_id] + } + index "job_history_status_idx" { + columns = [column.status] + } }