LP#1643932 - Fix search slowness when patron searching by username
authorChris Sharp <csharp@georgialibraries.org>
Mon, 5 Dec 2016 22:46:02 +0000 (17:46 -0500)
committerGalen Charlton <gmc@equinoxinitiative.org>
Tue, 14 Feb 2017 14:14:40 +0000 (09:14 -0500)
Bug 1501781 introduced a feature to improve patron name searching,
but which was causing very slow queries when searching by username.
Adding an index to username solves the slowness problem.

Suggested by Mike Rylander.

Signed-off-by: Chris Sharp <csharp@georgialibraries.org>
Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Open-ILS/src/sql/Pg/005.schema.actors.sql
Open-ILS/src/sql/Pg/upgrade/XXXX.schema.actor_usr_usrname_unaccent_idx.sql [new file with mode: 0644]

index d44ac53..90a351d 100644 (file)
@@ -85,6 +85,7 @@ CREATE INDEX actor_usr_family_name_idx ON actor.usr (evergreen.lowercase(family_
 CREATE INDEX actor_usr_first_given_name_unaccent_idx ON actor.usr (evergreen.unaccent_and_squash(first_given_name));
 CREATE INDEX actor_usr_second_given_name_unaccent_idx ON actor.usr (evergreen.unaccent_and_squash(second_given_name));
 CREATE INDEX actor_usr_family_name_unaccent_idx ON actor.usr (evergreen.unaccent_and_squash(family_name));
+CREATE INDEX actor_usr_usrname_unaccent_idx ON actor.usr (evergreen.unaccent_and_squash(usrname));
 
 CREATE INDEX actor_usr_usrname_idx ON actor.usr (evergreen.lowercase(usrname));
 CREATE INDEX actor_usr_email_idx ON actor.usr (evergreen.lowercase(email));
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.actor_usr_usrname_unaccent_idx.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.actor_usr_usrname_unaccent_idx.sql
new file mode 100644 (file)
index 0000000..5bf7167
--- /dev/null
@@ -0,0 +1,8 @@
+BEGIN;
+
+SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version); -- csharp/miker
+
+CREATE INDEX actor_usr_usrname_unaccent_idx ON actor.usr (evergreen.unaccent_and_squash(usrname));
+
+
+COMMIT;