Mercurial > hg > orthanc-databases
changeset 452:6780dd8b0a66 pg-transactions
fix latency measure for ODBC
author | Alain Mazy <am@osimis.io> |
---|---|
date | Thu, 18 Jan 2024 10:04:43 +0100 |
parents | 392ac133a491 |
children | 0a8b34e3a337 |
files | Framework/Common/DatabaseManager.cpp Framework/Common/DatabaseManager.h Framework/Plugins/IndexBackend.cpp |
diffstat | 3 files changed, 31 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/Framework/Common/DatabaseManager.cpp Wed Jan 17 19:31:23 2024 +0100 +++ b/Framework/Common/DatabaseManager.cpp Thu Jan 18 10:04:43 2024 +0100 @@ -641,6 +641,16 @@ void DatabaseManager::StandaloneStatement::Execute(const Dictionary& parameters) { + ExecuteInternal(parameters, true); + } + + void DatabaseManager::StandaloneStatement::ExecuteWithoutResult(const Dictionary& parameters) + { + ExecuteInternal(parameters, false); + } + + void DatabaseManager::StandaloneStatement::ExecuteInternal(const Dictionary& parameters, bool withResults) + { try { std::unique_ptr<Query> query(ReleaseQuery()); @@ -652,7 +662,14 @@ statement_.reset(GetManager().GetDatabase().Compile(*query)); assert(statement_.get() != NULL); - SetResult(GetTransaction().Execute(*statement_, parameters)); + if (withResults) + { + SetResult(GetTransaction().Execute(*statement_, parameters)); + } + else + { + GetTransaction().Execute(*statement_, parameters); + } } catch (Orthanc::OrthancException& e) {
--- a/Framework/Common/DatabaseManager.h Wed Jan 17 19:31:23 2024 +0100 +++ b/Framework/Common/DatabaseManager.h Thu Jan 18 10:04:43 2024 +0100 @@ -253,6 +253,17 @@ } void Execute(const Dictionary& parameters); + + void ExecuteWithoutResult() + { + Dictionary parameters; + ExecuteWithoutResult(parameters); + } + + void ExecuteWithoutResult(const Dictionary& parameters); + + private: + void ExecuteInternal(const Dictionary& parameters, bool withResults); }; }; }
--- a/Framework/Plugins/IndexBackend.cpp Wed Jan 17 19:31:23 2024 +0100 +++ b/Framework/Plugins/IndexBackend.cpp Thu Jan 18 10:04:43 2024 +0100 @@ -2884,13 +2884,11 @@ for (int i = 0; i < 11; i++) { - DatabaseManager::CachedStatement statement( - STATEMENT_FROM_HERE, manager, - "SELECT 1"); + DatabaseManager::StandaloneStatement statement(manager, "SELECT 1"); Orthanc::Toolbox::ElapsedTimer timer; - statement.Execute(); + statement.ExecuteWithoutResult(); measures.push_back(timer.GetElapsedMicroseconds()); }