update pragma settings for improved database performance
This commit is contained in:
parent
54235f4fb1
commit
8dbc0fe033
2 changed files with 12 additions and 2 deletions
|
@ -18,7 +18,7 @@ use std::{
|
||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
rc::Rc,
|
rc::Rc,
|
||||||
sync::Arc,
|
sync::Arc,
|
||||||
time::SystemTime,
|
time::{Instant, SystemTime},
|
||||||
};
|
};
|
||||||
use util::TryFutureExt;
|
use util::TryFutureExt;
|
||||||
|
|
||||||
|
@ -54,6 +54,12 @@ impl VectorDatabase {
|
||||||
let path = path.clone();
|
let path = path.clone();
|
||||||
async move {
|
async move {
|
||||||
let mut connection = rusqlite::Connection::open(&path)?;
|
let mut connection = rusqlite::Connection::open(&path)?;
|
||||||
|
|
||||||
|
connection.pragma_update(None, "journal_mode", "wal")?;
|
||||||
|
connection.pragma_update(None, "synchronous", "normal")?;
|
||||||
|
connection.pragma_update(None, "cache_size", 1000000)?;
|
||||||
|
connection.pragma_update(None, "temp_store", "MEMORY")?;
|
||||||
|
|
||||||
while let Ok(transaction) = transactions_rx.recv().await {
|
while let Ok(transaction) = transactions_rx.recv().await {
|
||||||
transaction(&mut connection);
|
transaction(&mut connection);
|
||||||
}
|
}
|
||||||
|
@ -222,6 +228,7 @@ impl VectorDatabase {
|
||||||
|
|
||||||
let file_id = db.last_insert_rowid();
|
let file_id = db.last_insert_rowid();
|
||||||
|
|
||||||
|
let t0 = Instant::now();
|
||||||
let mut query = db.prepare(
|
let mut query = db.prepare(
|
||||||
"
|
"
|
||||||
INSERT INTO documents
|
INSERT INTO documents
|
||||||
|
@ -229,6 +236,10 @@ impl VectorDatabase {
|
||||||
VALUES (?1, ?2, ?3, ?4, ?5, ?6)
|
VALUES (?1, ?2, ?3, ?4, ?5, ?6)
|
||||||
",
|
",
|
||||||
)?;
|
)?;
|
||||||
|
log::trace!(
|
||||||
|
"Preparing Query Took: {:?} milliseconds",
|
||||||
|
t0.elapsed().as_millis()
|
||||||
|
);
|
||||||
|
|
||||||
for document in documents {
|
for document in documents {
|
||||||
query.execute(params![
|
query.execute(params![
|
||||||
|
|
|
@ -81,7 +81,6 @@ pub fn init(
|
||||||
let semantic_index = SemanticIndex::new(
|
let semantic_index = SemanticIndex::new(
|
||||||
fs,
|
fs,
|
||||||
db_file_path,
|
db_file_path,
|
||||||
// Arc::new(embedding::DummyEmbeddings {}),
|
|
||||||
Arc::new(OpenAIEmbeddings {
|
Arc::new(OpenAIEmbeddings {
|
||||||
client: http_client,
|
client: http_client,
|
||||||
executor: cx.background(),
|
executor: cx.background(),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue