# HG changeset patch # User Alain Mazy # Date 1790171265 -7200 # Node ID 12bcfedb323aac2b94597ef9c746a7f537034bf2 # Parent b1f7adfc3847ead7ba9768fccada8008879e1c0b perform SQL analyze only once we have 50 studies in the DB diff -r b1f7adfc3847 -r 12bcfedb323a OrthancFramework/Sources/SQLite/Connection.cpp --- a/OrthancFramework/Sources/SQLite/Connection.cpp Thu Sep 17 19:49:04 2026 +0200 +++ b/OrthancFramework/Sources/SQLite/Connection.cpp Wed Sep 23 15:47:45 2026 +0200 @@ -54,7 +54,7 @@ #endif #include - +#include namespace Orthanc { @@ -238,9 +238,9 @@ { if (!DoesTableExist("sqlite_stat1")) // create the table if it does not exist yet and if there are enough data in the Resources table { - Statement countResources(*this, "SELECT COUNT(*) FROM Resources"); + Statement countResources(*this, std::string("SELECT COUNT(*) FROM Resources WHERE resourceType=") + boost::lexical_cast(ResourceType_Study)); countResources.Step(); - if (countResources.ColumnInt64(0) > 1000) // no need to ANALYZE if there are not enough data in the table + if (countResources.ColumnInt64(0) > 50) // no need to ANALYZE if there are not enough data in the table (wait for 50 studies) { CLOG(WARNING, SQLITE) << "SQLite: Performing first ANALYZE to improve the query planner"; Statement analyze(*this, "ANALYZE");