From 91c9f4a13d9aba163768420fa9502aa3dbcf3741 Mon Sep 17 00:00:00 2001 From: Aaron Kimbrell Date: Sat, 26 Sep 2026 18:45:39 -0500 Subject: [PATCH] perf(dashboard): live event object picker without a correlated EXISTS The picker's EXISTS on ComponentsRegistry (no index) took 2 to 4 s with the bundled SQLite for the treasure kinds; the same filter as IN takes under 10 ms. Co-Authored-By: Claude Opus 5.5 --- dDashboardServer/routes/LiveEventRoutes.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dDashboardServer/routes/LiveEventRoutes.cpp b/dDashboardServer/routes/LiveEventRoutes.cpp index a0bfbf05a..cca40ba29 100644 --- a/dDashboardServer/routes/LiveEventRoutes.cpp +++ b/dDashboardServer/routes/LiveEventRoutes.cpp @@ -420,9 +420,11 @@ namespace LiveEventRoutes { const auto& types = ObjectTypes(kind); std::string placeholders; for (size_t i = 0; i < types.size(); i++) placeholders += i ? ", ?" : "?"; + // IN, not a correlated EXISTS: ComponentsRegistry has no index, and the EXISTS form took seconds with the + // bundled SQLite for the kinds with thousands of objects auto stmt = CDClientDatabase::CreatePreppedStmt( "SELECT o.id, o.name, o.displayName, o.type FROM Objects o WHERE o.type IN (" + placeholders + ") " - "AND EXISTS (SELECT 1 FROM ComponentsRegistry c WHERE c.id = o.id AND c.component_type = ?) " + "AND o.id IN (SELECT c.id FROM ComponentsRegistry c WHERE c.component_type = ?) " "AND (? = '' OR o.name LIKE '%' || ? || '%' OR o.displayName LIKE '%' || ? || '%' OR o.id = ?) ORDER BY o.name LIMIT 60;"); int index = 1; for (const auto& type : types) stmt.bind(index++, type.c_str());