From d128dfa78ec25d216e6d17d53e74da88e3ede9fe Mon Sep 17 00:00:00 2001 From: Matthew Barbour Date: Thu, 20 Jun 2019 10:05:53 -0500 Subject: [PATCH] Added lower indexes for postgresql to tags.tag and users.name to speed up queries for them using lower() --- ext/upgrade/main.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/ext/upgrade/main.php b/ext/upgrade/main.php index 0aef4530..42522ad9 100644 --- a/ext/upgrade/main.php +++ b/ext/upgrade/main.php @@ -129,6 +129,20 @@ class Upgrade extends Extension log_info("upgrade", "Database at version 14"); $config->set_bool("in_upgrade", false); } + + if ($config->get_int("db_version") < 15) { + $config->set_bool("in_upgrade", true); + $config->set_int("db_version", 15); + + log_info("upgrade", "Adding lower indexes for postgresql use"); + if ($database->get_driver_name() == Database::PGSQL_DRIVER) { + $database->execute('CREATE INDEX tags_lower_tag_idx ON tags ((lower(tag)))'); + $database->execute('CREATE INDEX users_lower_name_idx ON users ((lower(name)))'); + } + + log_info("upgrade", "Database at version 15"); + $config->set_bool("in_upgrade", false); + } } public function get_priority(): int