Skip to content

Commit

Permalink
control-plane: use btree index for log_lines
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
psFried committed Sep 25, 2023
1 parent 7513a2f commit f5bf9c8
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions supabase/migrations/30_log_lines_index.sql
Original file line number Diff line number Diff line change
@@ -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;

0 comments on commit f5bf9c8

Please sign in to comment.