changeset 6457:ec8dd6953bba queues-timeout

upgrading from existing db by adding DicomIdentifiersIndex3
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 19 Nov 2025 15:51:36 +0100
parents 5fe14cbe8b9a
children 883178892d97
files NEWS OrthancServer/CMakeLists.txt OrthancServer/Sources/Database/InstallDicomIdentifiersIndex3.sql OrthancServer/Sources/Database/PrepareDatabase.sql OrthancServer/Sources/Database/SQLiteDatabaseWrapper.cpp
diffstat 5 files changed, 33 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/NEWS	Wed Nov 19 15:23:36 2025 +0100
+++ b/NEWS	Wed Nov 19 15:51:36 2025 +0100
@@ -1,8 +1,6 @@
 Pending changes in the mainline
 ===============================
 
-TODO: finalize DicomIdentifiersIndex (upgrade from existing DB)
-
 General
 -------
 
--- a/OrthancServer/CMakeLists.txt	Wed Nov 19 15:23:36 2025 +0100
+++ b/OrthancServer/CMakeLists.txt	Wed Nov 19 15:51:36 2025 +0100
@@ -267,6 +267,7 @@
   INSTALL_DELETED_FILES             ${CMAKE_SOURCE_DIR}/Sources/Database/InstallDeletedFiles.sql
   INSTALL_KEY_VALUE_STORES_AND_QUEUES ${CMAKE_SOURCE_DIR}/Sources/Database/InstallKeyValueStoresAndQueues.sql
   ADD_TIMEOUT_TO_QUEUES             ${CMAKE_SOURCE_DIR}/Sources/Database/AddTimeoutToQueues.sql
+  INSTALL_DICOM_IDENTIFIERS_INDEX_3 ${CMAKE_SOURCE_DIR}/Sources/Database/InstallDicomIdentifiersIndex3.sql
   )
 
 if (STANDALONE_BUILD)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/OrthancServer/Sources/Database/InstallDicomIdentifiersIndex3.sql	Wed Nov 19 15:51:36 2025 +0100
@@ -0,0 +1,22 @@
+-- Orthanc - A Lightweight, RESTful DICOM Store
+-- Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
+-- Department, University Hospital of Liege, Belgium
+-- Copyright (C) 2017-2023 Osimis S.A., Belgium
+-- Copyright (C) 2024-2025 Orthanc Team SRL, Belgium
+-- Copyright (C) 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
+--
+-- This program is free software: you can redistribute it and/or
+-- modify it under the terms of the GNU General Public License as
+-- published by the Free Software Foundation, either version 3 of the
+-- License, or (at your option) any later version.
+--
+-- This program is distributed in the hope that it will be useful, but
+-- WITHOUT ANY WARRANTY; without even the implied warranty of
+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+-- General Public License for more details.
+--
+-- You should have received a copy of the GNU General Public License
+-- along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+
+CREATE INDEX DicomIdentifiersIndex3 ON DicomIdentifiers(tagGroup, tagElement, value);
--- a/OrthancServer/Sources/Database/PrepareDatabase.sql	Wed Nov 19 15:23:36 2025 +0100
+++ b/OrthancServer/Sources/Database/PrepareDatabase.sql	Wed Nov 19 15:51:36 2025 +0100
@@ -110,8 +110,6 @@
 -- CREATE INDEX DicomIdentifiersIndex2 ON DicomIdentifiers(tagGroup, tagElement);  -- disabled in 1.12.10
 CREATE INDEX DicomIdentifiersIndexValues ON DicomIdentifiers(value COLLATE BINARY);
 
-CREATE INDEX DicomIdentifiersIndexGroupElementValue ON DicomIdentifiers(tagGroup, tagElement, value); -- added in 1.12.10
-
 CREATE INDEX ChangesIndex ON Changes(internalId);
 
 
@@ -154,7 +152,8 @@
 -- new in Orthanc 1.12.8 ------------------------- equivalent to InstallKeyValueStoresAndQueues.sql
 ${INSTALL_KEY_VALUE_STORES_AND_QUEUES}
 
--- new in Orthanc 1.12.10 ------------------------- equivalent to AddTimeoutToQueues.sql
+-- new in Orthanc 1.12.10 ------------------------ equivalent to AddTimeoutToQueues.sql
+${INSTALL_DICOM_IDENTIFIERS_INDEX_3}  -- This greatly speeds up the database
 ${ADD_TIMEOUT_TO_QUEUES}
 
 
--- a/OrthancServer/Sources/Database/SQLiteDatabaseWrapper.cpp	Wed Nov 19 15:23:36 2025 +0100
+++ b/OrthancServer/Sources/Database/SQLiteDatabaseWrapper.cpp	Wed Nov 19 15:51:36 2025 +0100
@@ -2769,6 +2769,7 @@
         InjectEmbeddedScript(query, "${INSTALL_DELETED_FILES}", ServerResources::INSTALL_DELETED_FILES);
         InjectEmbeddedScript(query, "${INSTALL_KEY_VALUE_STORES_AND_QUEUES}", ServerResources::INSTALL_KEY_VALUE_STORES_AND_QUEUES);
         InjectEmbeddedScript(query, "${ADD_TIMEOUT_TO_QUEUES}", ServerResources::ADD_TIMEOUT_TO_QUEUES);
+        InjectEmbeddedScript(query, "${INSTALL_DICOM_IDENTIFIERS_INDEX_3}", ServerResources::INSTALL_DICOM_IDENTIFIERS_INDEX_3);
 
         db_.Execute(query);
       }
@@ -2836,6 +2837,13 @@
         }
 
         // New in Orthanc 1.12.10
+        if (!db_.DoesIndexExist("DicomIdentifiersIndex3"))
+        {
+          LOG(INFO) << "Installing the \"DicomIdentifiersIndex3\" index";
+          ExecuteEmbeddedScript(db_, ServerResources::INSTALL_DICOM_IDENTIFIERS_INDEX_3);
+        }
+
+        // New in Orthanc 1.12.10
         if (!db_.DoesColumnExist("Queues", "reservedUntil"))
         {
           LOG(INFO) << "Adding timeout column to the \"Queues\" table";