Skip to content

Commit

Permalink
Merge pull request #2729 from rouault/analyze_db
Browse files Browse the repository at this point in the history
Database: add a ANALYZE step during proj.db creation
  • Loading branch information
rouault authored May 24, 2021
2 parents 08d4b05 + 1720b05 commit e814dce
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 2 additions & 0 deletions data/sql/commit.sql
Original file line number Diff line number Diff line change
Expand Up @@ -301,4 +301,6 @@ INSERT INTO dummy DEFAULT VALUES;
DROP TRIGGER final_checks;
DROP TABLE dummy;

ANALYZE;

VACUUM;
7 changes: 5 additions & 2 deletions src/iso19111/factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -819,7 +819,9 @@ std::vector<std::string> DatabaseContext::Private::getDatabaseStructure() {
: "db_0.");
const auto sqlBegin("SELECT sql||';' FROM " + dbNamePrefix +
"sqlite_master WHERE type = ");
const char *const objectTypes[] = {"'table'", "'view'", "'trigger'"};
const char *const objectTypes[] = {"'table' AND "
"name NOT LIKE 'sqlite_stat%'",
"'view'", "'trigger'"};
std::vector<std::string> res;
for (const auto &objectType : objectTypes) {
const auto sqlRes = run(sqlBegin + objectType);
Expand All @@ -846,7 +848,8 @@ void DatabaseContext::Private::attachExtraDatabases(
assert(sqlite_handle_);

auto tables =
run("SELECT name FROM sqlite_master WHERE type IN ('table', 'view')");
run("SELECT name FROM sqlite_master WHERE type IN ('table', 'view') "
"AND name NOT LIKE 'sqlite_stat%'");
std::map<std::string, std::vector<std::string>> tableStructure;
for (const auto &rowTable : tables) {
auto tableName = rowTable[0];
Expand Down

0 comments on commit e814dce

Please sign in to comment.