diff --git a/crates/util/cometindex/src/indexer.rs b/crates/util/cometindex/src/indexer.rs index aa577e33a3..fa21a0af1d 100644 --- a/crates/util/cometindex/src/indexer.rs +++ b/crates/util/cometindex/src/indexer.rs @@ -141,7 +141,7 @@ impl Indexer { let watermark = current_watermark.unwrap_or(0); // Calculate new events count since the last watermark - sqlx::query_as::<_, (i64,)>("SELECT COUNT(*) FROM events WHERE rowid > $1") + sqlx::query_as::<_, (i64,)>("SELECT MAX(rowid) - $1 FROM events") .bind(watermark) .fetch_one(src_db) .await