From e357eaf5d7861fcd8773a1f3cf89b483a033e1e6 Mon Sep 17 00:00:00 2001 From: Chae Jubb Date: Thu, 2 Dec 2021 15:57:43 -0500 Subject: [PATCH] reuse_topic: Add index to timestamp bindings table (#9379) We want `compact_timestamp_bindings` to use only indexed lookups. We can accumulate a large number of uncompacted timestamps if the sink enters into an errored state or the frontier stops moving forward for some reason. Because of this, we want the queries in `compact_timestamp_bindings` to be completed in near constant-time. Therefor, we add a `(sid, timestamp)` index so that we can do these lookups much more quickly. --- src/coord/src/catalog/storage.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/coord/src/catalog/storage.rs b/src/coord/src/catalog/storage.rs index c51cecb2c1f9e..755758e7afd81 100644 --- a/src/coord/src/catalog/storage.rs +++ b/src/coord/src/catalog/storage.rs @@ -125,6 +125,10 @@ const MIGRATIONS: &[&str] = &[ // Introduced in v0.9.12. "INSERT INTO schemas (database_id, name) VALUES (NULL, 'information_schema');", + // Adds index to timestamp table to more efficiently compact timestamps. + // + // Introduced in v0.12.0. + "CREATE INDEX timestamps_sid_timestamp ON timestamps (sid, timestamp)", // Add new migrations here. // // Migrations should be preceded with a comment of the following form: