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