Enable auto vacuum.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4372 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
parent
d3029639de
commit
3e5abf3a4d
2
Makefile
2
Makefile
@ -270,7 +270,7 @@ $(SQLITE_OBJS): CFLAGS += \
|
|||||||
-DSQLITE_ENABLE_FTS5 \
|
-DSQLITE_ENABLE_FTS5 \
|
||||||
-DSQLITE_ENABLE_JSON1 \
|
-DSQLITE_ENABLE_JSON1 \
|
||||||
-DSQLITE_LIKE_DOESNT_MATCH_BLOBS \
|
-DSQLITE_LIKE_DOESNT_MATCH_BLOBS \
|
||||||
-DSQLITE_MAX_ATTACHED=0 \
|
-DSQLITE_MAX_ATTACHED=1 \
|
||||||
-DSQLITE_MAX_COLUMN=100 \
|
-DSQLITE_MAX_COLUMN=100 \
|
||||||
-DSQLITE_MAX_COMPOUND_SELECT=300 \
|
-DSQLITE_MAX_COMPOUND_SELECT=300 \
|
||||||
-DSQLITE_MAX_EXPR_DEPTH=40 \
|
-DSQLITE_MAX_EXPR_DEPTH=40 \
|
||||||
|
20
src/ssb.db.c
20
src/ssb.db.c
@ -77,6 +77,25 @@ void tf_ssb_db_init(tf_ssb_t* ssb)
|
|||||||
{
|
{
|
||||||
sqlite3* db = tf_ssb_acquire_db_writer(ssb);
|
sqlite3* db = tf_ssb_acquire_db_writer(ssb);
|
||||||
_tf_ssb_db_init_internal(db);
|
_tf_ssb_db_init_internal(db);
|
||||||
|
|
||||||
|
sqlite3_stmt* statement = NULL;
|
||||||
|
int auto_vacuum = 0;
|
||||||
|
if (sqlite3_prepare(db, "PRAGMA auto_vacuum", -1, &statement, NULL) == SQLITE_OK)
|
||||||
|
{
|
||||||
|
if (sqlite3_step(statement) == SQLITE_ROW)
|
||||||
|
{
|
||||||
|
auto_vacuum = sqlite3_column_int(statement, 0);
|
||||||
|
}
|
||||||
|
sqlite3_finalize(statement);
|
||||||
|
}
|
||||||
|
if (auto_vacuum != 1 /* FULL */)
|
||||||
|
{
|
||||||
|
tf_printf("Enabling auto-vacuum and performing full vacuum.\n");
|
||||||
|
_tf_ssb_db_exec(db, "PRAGMA auto_vacuum = FULL");
|
||||||
|
_tf_ssb_db_exec(db, "VACUUM main");
|
||||||
|
tf_printf("All clean.\n");
|
||||||
|
}
|
||||||
|
|
||||||
_tf_ssb_db_exec(db,
|
_tf_ssb_db_exec(db,
|
||||||
"CREATE TABLE IF NOT EXISTS messages ("
|
"CREATE TABLE IF NOT EXISTS messages ("
|
||||||
" author TEXT,"
|
" author TEXT,"
|
||||||
@ -196,7 +215,6 @@ void tf_ssb_db_init(tf_ssb_t* ssb)
|
|||||||
bool need_add_sequence_before_author = true;
|
bool need_add_sequence_before_author = true;
|
||||||
bool need_convert_timestamp_to_real = false;
|
bool need_convert_timestamp_to_real = false;
|
||||||
|
|
||||||
sqlite3_stmt* statement = NULL;
|
|
||||||
if (sqlite3_prepare(db, "PRAGMA table_info(messages)", -1, &statement, NULL) == SQLITE_OK)
|
if (sqlite3_prepare(db, "PRAGMA table_info(messages)", -1, &statement, NULL) == SQLITE_OK)
|
||||||
{
|
{
|
||||||
int result = SQLITE_OK;
|
int result = SQLITE_OK;
|
||||||
|
@ -1188,10 +1188,7 @@ static void _tf_ssb_rpc_delete_blobs_work(uv_work_t* work)
|
|||||||
tf_ssb_release_db_writer(ssb, db);
|
tf_ssb_release_db_writer(ssb, db);
|
||||||
int64_t duration_ms = (uv_hrtime() - start_ns) / 1000000LL;
|
int64_t duration_ms = (uv_hrtime() - start_ns) / 1000000LL;
|
||||||
tf_printf("Deleted %d blobs in %d ms.\n", deleted, (int)duration_ms);
|
tf_printf("Deleted %d blobs in %d ms.\n", deleted, (int)duration_ms);
|
||||||
if (deleted)
|
_tf_ssb_rpc_start_delete_blobs(ssb, deleted ? (int)duration_ms : (15 * 60 * 1000));
|
||||||
{
|
|
||||||
_tf_ssb_rpc_start_delete_blobs(ssb, (int)duration_ms);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _tf_ssb_rpc_delete_blobs_after_work(uv_work_t* work, int status)
|
static void _tf_ssb_rpc_delete_blobs_after_work(uv_work_t* work, int status)
|
||||||
|
Loading…
Reference in New Issue
Block a user