Skip to content

Commit

Permalink
commit every repeat with conn
Browse files Browse the repository at this point in the history
  • Loading branch information
neilyio committed Apr 4, 2024
1 parent c9de678 commit 5979d25
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions cargo-paradedb/src/subcommand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,11 @@ pub async fn insert_benchmark_corpus(glob: &str, table: &str, url: Option<&str>)
.unwrap_or_else(|| std::env::var("DATABASE_URL").ok().unwrap_or_default()),
)?;
let mut conn = PgConnection::connect_with(&conn_opts).await?;
let mut transaction = sqlx::Connection::begin(&mut conn).await?;
// let mut transaction = sqlx::Connection::begin(&mut conn).await?;

// Ensure the table exists;
sqlx::query(&BenchLog::create_table_statement(table))
.execute(&mut *transaction)
.execute(&mut conn) // MAKE TRANSACTION
.await?;

// Read JSON data files, chunked to not overload Postgres.
Expand All @@ -145,12 +145,11 @@ pub async fn insert_benchmark_corpus(glob: &str, table: &str, url: Option<&str>)
QueryBuilder::<Postgres>::new(BenchLog::insert_header(table))
.push_values(chunk, BenchLog::insert_push_values)
.build()
.execute(&mut *transaction)
.execute(&mut conn)
.await?;

// Everything above happens in a single transaction, so all will
transaction.commit().await?;
}
// // Everything above happens in a single transaction, so all will
// transaction.commit().await?;

Ok(())
}

0 comments on commit 5979d25

Please sign in to comment.