Mercurial > hg > orthanc-databases
diff PostgreSQL/Plugins/PostgreSQLIndex.cpp @ 72:8dd29af7c844 db-changes
new extension: FastTotalSize
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 04 Jan 2019 14:43:35 +0100 |
parents | d40c5fecd160 |
children | aa81c1c80c75 |
line wrap: on
line diff
--- a/PostgreSQL/Plugins/PostgreSQLIndex.cpp Fri Jan 04 13:51:52 2019 +0100 +++ b/PostgreSQL/Plugins/PostgreSQLIndex.cpp Fri Jan 04 14:43:35 2019 +0100 @@ -187,6 +187,27 @@ } } + { + PostgreSQLTransaction t(*db); + + int hasFastTotalSize = 0; + if (!LookupGlobalIntegerProperty(hasFastTotalSize, *db, t, + Orthanc::GlobalProperty_GetTotalSizeIsFast) || + hasFastTotalSize != 1) + { + LOG(INFO) << "Installing the FastTotalSize extension"; + + std::string query; + Orthanc::EmbeddedResources::GetFileResource + (query, Orthanc::EmbeddedResources::POSTGRESQL_FAST_TOTAL_SIZE); + db->Execute(query); + + SetGlobalIntegerProperty(*db, t, Orthanc::GlobalProperty_GetTotalSizeIsFast, 1); + + t.Commit(); + } + } + return db.release(); } @@ -220,6 +241,34 @@ } + uint64_t PostgreSQLIndex::GetTotalCompressedSize() + { + // Fast version if extension "./FastTotalSize.sql" is installed + DatabaseManager::CachedStatement statement( + STATEMENT_FROM_HERE, GetManager(), + "SELECT value FROM GlobalIntegers WHERE key = 0"); + + statement.SetReadOnly(true); + statement.Execute(); + + return static_cast<uint64_t>(ReadInteger64(statement, 0)); + } + + + uint64_t PostgreSQLIndex::GetTotalUncompressedSize() + { + // Fast version if extension "./FastTotalSize.sql" is installed + DatabaseManager::CachedStatement statement( + STATEMENT_FROM_HERE, GetManager(), + "SELECT value FROM GlobalIntegers WHERE key = 1"); + + statement.SetReadOnly(true); + statement.Execute(); + + return static_cast<uint64_t>(ReadInteger64(statement, 0)); + } + + void PostgreSQLIndex::CreateInstance(OrthancPluginCreateInstanceResult& result, const char* hashPatient, const char* hashStudy,