Skip to content

Commit 992903e

Browse files
committed
adding index to improve query performance
1 parent 27577d4 commit 992903e

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

nexus/catalog/src/lib.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,19 @@ async fn run_migrations(client: &mut Client) -> anyhow::Result<()> {
7777
migration.version()
7878
);
7979
}
80-
Ok(())
80+
run_non_transactional_migrations(client).await?;
81+
}
82+
83+
async fn run_non_transactional_migrations(client: &Client) -> anyhow::Result<()> {
84+
const STATEMENTS: &[&str] = &[
85+
"CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_cdc_batches_flow_name_batch_id_open ON peerdb_stats.cdc_batches (flow_name, batch_id) WHERE end_time IS NULL",
86+
];
87+
for stmt in STATEMENTS {
88+
client
89+
.batch_execute(stmt)
90+
.await
91+
.with_context(|| format!("Failed to apply non-transactional migration: {stmt}"))?;
92+
}
8193
}
8294

8395
#[derive(Debug, Clone)]

0 commit comments

Comments
 (0)