PRAGMA optimize

This commit is contained in:
Natsumi
2025-03-14 07:25:00 +13:00
parent 9ed93ad2eb
commit 2fd3dcc1a8
4 changed files with 12 additions and 2 deletions

View File

@@ -34,7 +34,7 @@ namespace VRCX
if (!string.IsNullOrEmpty(jsonDataSource))
dataSource = jsonDataSource;
m_Connection = new SQLiteConnection($"Data Source=\"{dataSource}\";Version=3;PRAGMA locking_mode=NORMAL;PRAGMA busy_timeout=5000;PRAGMA journal_mode=WAL;", true);
m_Connection = new SQLiteConnection($"Data Source=\"{dataSource}\";Version=3;PRAGMA locking_mode=NORMAL;PRAGMA busy_timeout=5000;PRAGMA journal_mode=WAL;PRAGMA optimize=0x10002;", true);
m_Connection.Open();
}

View File

@@ -18132,6 +18132,7 @@ console.log(`isLinux: ${LINUX}`);
await database.fixBrokenGameLogDisplayNames(); // fix gameLog display names "DisplayName (userId)"
await database.upgradeDatabaseVersion(); // update database version
await database.vacuum(); // succ
await database.optimize();
await configRepository.setInt(
'VRCX_databaseVersion',
databaseVersion

View File

@@ -24,7 +24,8 @@ export default class extends baseClass {
nextDiscordUpdate: 0,
nextAutoStateChange: 0,
nextGetLogCheck: 0,
nextGameRunningCheck: 0
nextGameRunningCheck: 0,
nextDatabaseOptimize: 3600
};
_methods = {
@@ -105,6 +106,10 @@ export default class extends baseClass {
AppApi.CheckGameRunning();
}
}
if (--this.nextDatabaseOptimize <= 0) {
this.nextDatabaseOptimize = 86400; // 1 day
database.optimize();
}
}
} catch (err) {
API.isRefreshFriendsLoading = false;

View File

@@ -2754,6 +2754,10 @@ class Database {
await sqliteService.executeNonQuery('VACUUM');
}
async optimize() {
await sqliteService.executeNonQuery('PRAGMA optimize');
}
async getInstanceJoinHistory() {
var oneWeekAgo = new Date(Date.now() - 604800000).toJSON();
var instances = new Map();