From 1cf02e0473bd1409d908e0040e656b7d3efc5b93 Mon Sep 17 00:00:00 2001 From: Phil Date: Mon, 25 Sep 2023 12:17:25 -0400 Subject: [PATCH] control-plane: use btree index for log_lines Replaces the current BRIN index on the `internal.log_lines` table with a btree index. The BRIN index would require queries to use the `logged_at` timestamp in the where clause in order for it to be effective. Neither the UI or flowctl do that currently. The btree index works well when only filtering on token, so this changes to just using that. --- supabase/migrations/30_log_lines_index.sql | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 supabase/migrations/30_log_lines_index.sql diff --git a/supabase/migrations/30_log_lines_index.sql b/supabase/migrations/30_log_lines_index.sql new file mode 100644 index 0000000000..c7f1fcab0f --- /dev/null +++ b/supabase/migrations/30_log_lines_index.sql @@ -0,0 +1,11 @@ + +-- The previous BRIN index on internal.log_lines is ineffective for queries that don't +-- supply a where condition on the `logged_at` timestamp. Currently, that represents +-- all queries against that table. This drops the old BRIN index in favor of a regular +-- btree index, which is effective when queries only provide the `token`. + +begin; +create index idx_logs_token on internal.log_lines (token); +drop index internal.idx_logs_token_logged_at; +commit; +