1
0
Fork 0

Change the way the nav-cache is rebuilt.

Instead of deleting all table contents, actually remove the entire file on disk and re-create. This is fractionally more work, but removes any possibility of stale indices or missing deletes causing clutter after rebuilds. My suspicion is, this is cause the erratic performance some people have seen with the airports search dialog, so will back-port to 2.10.
This commit is contained in:
James Turner 2013-02-03 22:24:40 +00:00
parent 5ef475865c
commit 1dd3b40907

View file

@ -206,12 +206,7 @@ public:
~NavDataCachePrivate() ~NavDataCachePrivate()
{ {
BOOST_FOREACH(sqlite3_stmt_ptr stmt, prepared) { close();
sqlite3_finalize(stmt);
}
prepared.clear();
sqlite3_close(db);
} }
void init() void init()
@ -257,6 +252,15 @@ public:
prepareQueries(); prepareQueries();
} }
void close()
{
BOOST_FOREACH(sqlite3_stmt_ptr stmt, prepared) {
sqlite3_finalize(stmt);
}
prepared.clear();
sqlite3_close(db);
}
void checkCacheFile() void checkCacheFile()
{ {
SG_LOG(SG_NAVCACHE, SG_INFO, "running DB integrity check"); SG_LOG(SG_NAVCACHE, SG_INFO, "running DB integrity check");
@ -1179,20 +1183,11 @@ bool NavDataCache::rebuild()
void NavDataCache::doRebuild() void NavDataCache::doRebuild()
{ {
try { try {
Transaction txn(this); d->close(); // completely close the sqlite object
d->runSQL("DELETE FROM positioned"); d->path.remove(); // remove the file on disk
d->runSQL("DELETE FROM airport"); d->init(); // star again from scratch
d->runSQL("DELETE FROM runway");
d->runSQL("DELETE FROM navaid");
d->runSQL("DELETE FROM comm");
d->runSQL("DELETE FROM octree");
d->runSQL("DELETE FROM airway");
d->runSQL("DELETE FROM airway_edge");
d->runSQL("DELETE FROM taxi_node");
d->runSQL("DELETE FROM parking");
d->runSQL("DELETE FROM groundnet_edge");
d->runSQL("DELETE FROM stat_cache");
Transaction txn(this);
// initialise the root octree node // initialise the root octree node
d->runSQL("INSERT INTO octree (rowid, children) VALUES (1, 0)"); d->runSQL("INSERT INTO octree (rowid, children) VALUES (1, 0)");