changeset 7169:47f2edc0200d

cleanup + disabled analyze/optimize for good
author Alain Mazy <am@orthanc.team>
date Thu, 08 Oct 2026 10:34:30 +0200
parents 35d32f786499
children bb6c9baf347d
files NEWS OrthancFramework/Sources/SQLite/Connection.cpp OrthancServer/Sources/Database/SQLiteDatabaseWrapper.cpp
diffstat 3 files changed, 2 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/NEWS	Thu Oct 08 09:15:18 2026 +0200
+++ b/NEWS	Thu Oct 08 10:34:30 2026 +0200
@@ -6,8 +6,6 @@
 
 * With the default SQLite database:
   - Optimized some queries to access single resources.
-  - Optimized many queries thanks to improved query planning.  An Optimization step can
-    sometimes run at startup which slows down the Orthanc startup.
   - Added/updated 2 indexes: the first startup with this version migth be slower to rebuild
     these indexes.
 
--- a/OrthancFramework/Sources/SQLite/Connection.cpp	Thu Oct 08 09:15:18 2026 +0200
+++ b/OrthancFramework/Sources/SQLite/Connection.cpp	Thu Oct 08 10:34:30 2026 +0200
@@ -232,6 +232,7 @@
       return false;
     }
 
+    // currently not used but it might be useful in the future if we want to add an "optimize-db" API route
     void Connection::Optimize(bool onlyIfStatsDontExistsYet)
     {
       if (onlyIfStatsDontExistsYet)
--- a/OrthancServer/Sources/Database/SQLiteDatabaseWrapper.cpp	Thu Oct 08 09:15:18 2026 +0200
+++ b/OrthancServer/Sources/Database/SQLiteDatabaseWrapper.cpp	Thu Oct 08 10:34:30 2026 +0200
@@ -2899,9 +2899,6 @@
           LOG(INFO) << "Installing the \"AttachedFilesUuidIndex\" index";
           ExecuteEmbeddedScript(db_, ServerResources::INSTALL_ATTACHED_FILES_UUID_INDEX);
         }
-
-        // // New in Orthanc 1.13.1 run optimize at each startup, provided there are enough data to perform a relevant analysis
-        // Optimize(false);
       }
 
       transaction->Commit(0);
@@ -3035,7 +3032,7 @@
     }
   }
 
-
+  // currently not used but it might be useful in the future if we want to add an "optimize-db" API route
   bool SQLiteDatabaseWrapper::Optimize(bool onlyIfStatsDontExistsYet)
   {
     SQLite::Statement countResources(db_, std::string("SELECT COUNT(*) FROM Resources WHERE resourceType=") + boost::lexical_cast<std::string>(ResourceType_Study));    
@@ -3054,15 +3051,6 @@
   void SQLiteDatabaseWrapper::FlushToDisk()
   {
     boost::recursive_mutex::scoped_lock lock(mutex_);
-    // static bool hasRunOptimizeOnce = false;
-
-    // if (!hasRunOptimizeOnce)
-    // {
-    //   // This will run ANALYZE only once whe the Resources table contains reaches a predefined size and if there are no index statistics yet.
-    //   // Then, an OPTIMIZE step will run at each startup (and will execute ANALYZE if it makes sense)
-    //   hasRunOptimizeOnce = Optimize(true /* onlyIfStatsDontExistsYet */);
-    // }
-
     db_.FlushToDisk();
   }