From a135dfce9099a5978ade7d92d2ac7cabd65cb23b Mon Sep 17 00:00:00 2001 From: Sarjuuk Date: Sun, 9 Nov 2025 15:59:06 +0100 Subject: [PATCH] Profiler/Completions * add keyed col `exalted` to reputation completions table to speed up lookups --- endpoints/faction/faction.php | 2 +- setup/sql/01-db_structure.sql | 2 ++ setup/sql/02-db_initial_data.sql | 2 +- setup/sql/updates/1762700147_01.sql | 4 ++++ 4 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 setup/sql/updates/1762700147_01.sql diff --git a/endpoints/faction/faction.php b/endpoints/faction/faction.php index a5bd4867..cee5a79c 100644 --- a/endpoints/faction/faction.php +++ b/endpoints/faction/faction.php @@ -102,7 +102,7 @@ class FactionBaseResponse extends TemplateResponse implements ICache // profiler relateed (note that this is part of the cache. I don't think this is important enough to calc for every view) if (Cfg::get('PROFILER_ENABLE') && !($this->subject->getField('cuFlags') & CUSTOM_EXCLUDE_FOR_LISTVIEW)) { - $x = DB::Aowow()->selectCell('SELECT COUNT(1) FROM ?_profiler_completion_reputation WHERE `standing` >= ?d AND `factionId` = ?d', 42000, $this->typeId); + $x = DB::Aowow()->selectCell('SELECT COUNT(1) FROM ?_profiler_completion_reputation WHERE `exalted` = 1 AND `factionId` = ?d', $this->typeId); $y = DB::Aowow()->selectCell('SELECT COUNT(1) FROM ?_profiler_profiles WHERE `custom` = 0 AND `stub` = 0'); $infobox[] = Lang::profiler('attainedBy', [round(($x ?: 0) * 100 / ($y ?: 1))]); diff --git a/setup/sql/01-db_structure.sql b/setup/sql/01-db_structure.sql index 04d45dc6..76fcdf5a 100644 --- a/setup/sql/01-db_structure.sql +++ b/setup/sql/01-db_structure.sql @@ -1749,8 +1749,10 @@ CREATE TABLE `aowow_profiler_completion_reputation` ( `id` int(10) unsigned NOT NULL, `factionId` smallint(5) unsigned NOT NULL, `standing` mediumint(9) DEFAULT NULL, + `exalted` tinyint(1) GENERATED ALWAYS AS (`standing` >= 42000) STORED, KEY `id` (`id`), KEY `typeId` (`factionId`), + KEY `idx_exalted` (`exalted`), CONSTRAINT `FK_pr_completion_reputation` FOREIGN KEY (`id`) REFERENCES `aowow_profiler_profiles` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; diff --git a/setup/sql/02-db_initial_data.sql b/setup/sql/02-db_initial_data.sql index df0fbe49..0f64d138 100644 --- a/setup/sql/02-db_initial_data.sql +++ b/setup/sql/02-db_initial_data.sql @@ -71,7 +71,7 @@ UNLOCK TABLES; LOCK TABLES `aowow_dbversion` WRITE; /*!40000 ALTER TABLE `aowow_dbversion` DISABLE KEYS */; -INSERT INTO `aowow_dbversion` VALUES (1762543653,0,NULL,NULL); +INSERT INTO `aowow_dbversion` VALUES (1762700148,0,NULL,NULL); /*!40000 ALTER TABLE `aowow_dbversion` ENABLE KEYS */; UNLOCK TABLES; diff --git a/setup/sql/updates/1762700147_01.sql b/setup/sql/updates/1762700147_01.sql new file mode 100644 index 00000000..dd011d10 --- /dev/null +++ b/setup/sql/updates/1762700147_01.sql @@ -0,0 +1,4 @@ +ALTER TABLE aowow_profiler_completion_reputation + ADD COLUMN `exalted` tinyint(1) GENERATED ALWAYS AS (`standing` >= 42000) STORED AFTER `standing`, + ADD KEY idx_exalted (`exalted`) +;