mirror of
https://github.com/chatmail/core.git
synced 2026-05-22 16:26:31 +03:00
sql: enable auto_vacuum on all connections
This commit is contained in:
@@ -10,6 +10,7 @@
|
|||||||
### Fixes
|
### Fixes
|
||||||
- deltachat-rpc-server: do not block stdin while processing the request. #4041
|
- deltachat-rpc-server: do not block stdin while processing the request. #4041
|
||||||
deltachat-rpc-server now reads the next request as soon as previous request handler is spawned.
|
deltachat-rpc-server now reads the next request as soon as previous request handler is spawned.
|
||||||
|
- enable `auto_vacuum` on all SQL connections #2955
|
||||||
|
|
||||||
### API-Changes
|
### API-Changes
|
||||||
|
|
||||||
|
|||||||
31
src/sql.rs
31
src/sql.rs
@@ -213,6 +213,17 @@ impl Sql {
|
|||||||
Duration::from_secs(10).as_millis()
|
Duration::from_secs(10).as_millis()
|
||||||
))?;
|
))?;
|
||||||
c.pragma_update(None, "key", passphrase.clone())?;
|
c.pragma_update(None, "key", passphrase.clone())?;
|
||||||
|
// Try to enable auto_vacuum. This will only be
|
||||||
|
// applied if the database is new or after successful
|
||||||
|
// VACUUM, which usually happens before backup export.
|
||||||
|
// When auto_vacuum is INCREMENTAL, it is possible to
|
||||||
|
// use PRAGMA incremental_vacuum to return unused
|
||||||
|
// database pages to the filesystem.
|
||||||
|
c.pragma_update(None, "auto_vacuum", "INCREMENTAL".to_string())?;
|
||||||
|
|
||||||
|
c.pragma_update(None, "journal_mode", "WAL".to_string())?;
|
||||||
|
// Default synchronous=FULL is much slower. NORMAL is sufficient for WAL mode.
|
||||||
|
c.pragma_update(None, "synchronous", "NORMAL".to_string())?;
|
||||||
Ok(())
|
Ok(())
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -228,26 +239,6 @@ impl Sql {
|
|||||||
async fn try_open(&self, context: &Context, dbfile: &Path, passphrase: String) -> Result<()> {
|
async fn try_open(&self, context: &Context, dbfile: &Path, passphrase: String) -> Result<()> {
|
||||||
*self.pool.write().await = Some(Self::new_pool(dbfile, passphrase.to_string())?);
|
*self.pool.write().await = Some(Self::new_pool(dbfile, passphrase.to_string())?);
|
||||||
|
|
||||||
{
|
|
||||||
let conn = self.get_conn().await?;
|
|
||||||
tokio::task::block_in_place(move || -> Result<()> {
|
|
||||||
// Try to enable auto_vacuum. This will only be
|
|
||||||
// applied if the database is new or after successful
|
|
||||||
// VACUUM, which usually happens before backup export.
|
|
||||||
// When auto_vacuum is INCREMENTAL, it is possible to
|
|
||||||
// use PRAGMA incremental_vacuum to return unused
|
|
||||||
// database pages to the filesystem.
|
|
||||||
conn.pragma_update(None, "auto_vacuum", "INCREMENTAL".to_string())?;
|
|
||||||
|
|
||||||
// journal_mode is persisted, it is sufficient to change it only for one handle.
|
|
||||||
conn.pragma_update(None, "journal_mode", "WAL".to_string())?;
|
|
||||||
|
|
||||||
// Default synchronous=FULL is much slower. NORMAL is sufficient for WAL mode.
|
|
||||||
conn.pragma_update(None, "synchronous", "NORMAL".to_string())?;
|
|
||||||
Ok(())
|
|
||||||
})?;
|
|
||||||
}
|
|
||||||
|
|
||||||
self.run_migrations(context).await?;
|
self.run_migrations(context).await?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
Reference in New Issue
Block a user