Skip to content

Commit

Permalink
sqlite/fts: bundle queries on reindex
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonish committed Jun 25, 2024
1 parent 9e31ea8 commit 0fb7cb3
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/sqlite/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,17 +87,19 @@ async fn reindex_fts(conn: &mut SqliteConnection) -> anyhow::Result<usize> {
for row in rows {
let source: serde_json::Value = serde_json::from_str(&row.source)?;
let flat = extract_values(&source);
sqlx::query("UPDATE events SET source_values = ? WHERE rowid = ?")

let sql = r#"
UPDATE events SET source_values = ? WHERE rowid = ?;
INSERT INTO fts (rowid, timestamp, source_values) VALUES (?, ?, ?)"#;
sqlx::query(sql)
.bind(&flat)
.bind(row.rowid)
.execute(&mut *conn)
.await?;
sqlx::query("INSERT INTO fts (rowid, timestamp, source_values) VALUES (?, ?, ?)")
.bind(row.rowid)
.bind(row.timestamp)
.bind(&flat)
.execute(&mut *conn)
.await?;

next_id = row.rowid + 1;
count += 1;
}
Expand Down

0 comments on commit 0fb7cb3

Please sign in to comment.