[Rt-commit] rt branch 5.0/WIP-improve-text-indexes created. rt-5.0.2-223-g2785c0fd4a

BPS Git Server git at git.bestpractical.com
Wed May 4 14:46:11 UTC 2022


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "rt".

The branch, 5.0/WIP-improve-text-indexes has been created
        at  2785c0fd4aeb0a842b3eaad84722dfcc739cb5d8 (commit)

- Log -----------------------------------------------------------------
commit 2785c0fd4aeb0a842b3eaad84722dfcc739cb5d8
Author: Brian Conry <bconry at bestpractical.com>
Date:   Wed Mar 30 14:03:10 2022 -0500

    Oracle: Update indexes on char columns to use LOWER(column)
    
    Now that we're searching char columns with LOWER(), if the indexes in
    Oracle aren't built using LOWER() then they won't be used.

diff --git a/etc/schema.Oracle b/etc/schema.Oracle
index 0f47aee45e..09f0edc103 100644
--- a/etc/schema.Oracle
+++ b/etc/schema.Oracle
@@ -17,7 +17,7 @@ CREATE TABLE Attachments (
 );
 CREATE INDEX Attachments2 ON Attachments (TransactionId);
 CREATE INDEX Attachments3 ON Attachments (Parent, TransactionId);
-CREATE INDEX Attachments4 ON Attachments (Filename);
+CREATE INDEX Attachments4 ON Attachments (LOWER(Filename));
 
 
 CREATE SEQUENCE QUEUES_seq;
@@ -56,10 +56,10 @@ CREATE TABLE Links (
         Creator         NUMBER(11,0) DEFAULT 0 NOT NULL,
         Created         DATE
 );
-CREATE UNIQUE INDEX Links1 ON Links (Base, Target, Type);
-CREATE INDEX Links2 ON Links (Base, Type);
-CREATE INDEX Links3 ON Links (Target, Type);
-CREATE INDEX Links4 ON Links(Type,LocalBase);
+CREATE UNIQUE INDEX Links1 ON Links (LOWER(Base), LOWER(Target), LOWER(Type));
+CREATE INDEX Links2 ON Links (LOWER(Base), LOWER(Type));
+CREATE INDEX Links3 ON Links (LOWER(Target), LOWER(Type));
+CREATE INDEX Links4 ON Links(LOWER(Type), LocalBase);
 
 
 CREATE SEQUENCE PRINCIPALS_seq;
@@ -122,7 +122,7 @@ CREATE TABLE Transactions (
         Creator                 NUMBER(11,0) DEFAULT 0 NOT NULL,
         Created                 DATE
 );
-CREATE INDEX Transactions1 ON Transactions (ObjectType, ObjectId);
+CREATE INDEX Transactions1 ON Transactions (LOWER(ObjectType), ObjectId);
 
 
 CREATE SEQUENCE SCRIPS_seq;
@@ -172,7 +172,7 @@ CREATE TABLE ACL (
         LastUpdatedBy   NUMBER(11,0) DEFAULT 0 NOT NULL,
         LastUpdated     DATE
 );
-CREATE INDEX ACL1 ON ACL(RightName, ObjectType, ObjectId, PrincipalType, PrincipalId);
+CREATE INDEX ACL1 ON ACL(LOWER(RightName), LOWER(ObjectType), ObjectId, LOWER(PrincipalType), PrincipalId);
 
 
 CREATE SEQUENCE GROUPMEMBERS_seq;
@@ -273,7 +273,7 @@ CREATE TABLE Tickets (
 );
 CREATE INDEX Tickets1 ON Tickets (Queue, LOWER(Status));
 CREATE INDEX Tickets2 ON Tickets (Owner);
-CREATE INDEX Tickets6 ON Tickets (EffectiveId, Type);
+CREATE INDEX Tickets6 ON Tickets (EffectiveId, LOWER(Type));
 
 
 CREATE SEQUENCE SCRIPACTIONS_seq;
@@ -342,8 +342,8 @@ CREATE TABLE ObjectCustomFieldValues (
         Disabled        NUMBER(11,0) DEFAULT 0 NOT NULL
 );
 
-CREATE INDEX ObjectCustomFieldValues1 ON ObjectCustomFieldValues (Content); 
-CREATE INDEX ObjectCustomFieldValues2 ON ObjectCustomFieldValues (CustomField,ObjectType,ObjectId); 
+CREATE INDEX ObjectCustomFieldValues1 ON ObjectCustomFieldValues (LOWER(Content)); 
+CREATE INDEX ObjectCustomFieldValues2 ON ObjectCustomFieldValues (CustomField,LOWER(ObjectType),ObjectId); 
 
 CREATE SEQUENCE CUSTOMFIELDS_seq;
 CREATE TABLE CustomFields (
@@ -402,8 +402,8 @@ CREATE TABLE Attributes (
         LastUpdated             DATE
 );
 
-CREATE INDEX Attributes1 on Attributes(Name);
-CREATE INDEX Attributes2 on Attributes(ObjectType, ObjectId);
+CREATE INDEX Attributes1 on Attributes(LOWER(Name));
+CREATE INDEX Attributes2 on Attributes(LOWER(ObjectType), ObjectId);
 
 
 CREATE TABLE sessions (
diff --git a/etc/upgrade/5.0.3/schema.Oracle b/etc/upgrade/5.0.3/schema.Oracle
index 2d76c9de8b..390b4f222c 100644
--- a/etc/upgrade/5.0.3/schema.Oracle
+++ b/etc/upgrade/5.0.3/schema.Oracle
@@ -2,3 +2,27 @@ DROP INDEX Tickets1;
 CREATE INDEX Tickets1 ON Tickets (Queue, LOWER(Status));
 DROP INDEX AssetsStatus;
 CREATE INDEX AssetsStatus ON Assets (LOWER(Status));
+DROP INDEX ACL1;
+CREATE INDEX ACL1 ON ACL(LOWER(RightName), LOWER(ObjectType), ObjectId, LOWER(PrincipalType), PrincipalId);
+DROP INDEX Attachments4;
+CREATE INDEX Attachments4 ON Attachments (LOWER(Filename));
+DROP INDEX Attributes1;
+CREATE INDEX Attributes1 on Attributes(LOWER(Name));
+DROP INDEX Attributes2;
+CREATE INDEX Attributes2 on Attributes(LOWER(ObjectType), ObjectId);
+DROP INDEX Links1;
+CREATE UNIQUE INDEX Links1 ON Links (LOWER(Base), LOWER(Target), LOWER(Type));
+DROP INDEX Links2;
+CREATE INDEX Links2 ON Links (LOWER(Base)), LOWER(Type));
+DROP INDEX Links3;
+CREATE INDEX Links3 ON Links (LOWER(Target), LOWER(Type));
+DROP INDEX Links4;
+CREATE INDEX Links4 ON Links(LOWER(Type), LocalBase);
+DROP INDEX ObjectCustomFieldValues1;
+CREATE INDEX ObjectCustomFieldValues1 ON ObjectCustomFieldValues (LOWER(Content)); 
+DROP INDEX ObjectCustomFieldValues2;
+CREATE INDEX ObjectCustomFieldValues2 ON ObjectCustomFieldValues (CustomField, LOWER(ObjectType), ObjectId); 
+DROP INDEX Tickets6;
+CREATE INDEX Tickets6 ON Tickets (EffectiveId, LOWER(Type));
+DROP INDEX Transactions1;
+CREATE INDEX Transactions1 ON Transactions (LOWER(ObjectType), ObjectId);

commit 72bb706ca620391eeeb3f3a9ea09bf33d58688ce
Author: Brian Conry <bconry at bestpractical.com>
Date:   Wed Mar 30 13:10:45 2022 -0500

    Pg: Update indexes on char columns to use LOWER(column)
    
    Now that we're searching char columns with LOWER(), if the indexes in
    PostgreSQL aren't built using LOWER() then they won't be used.

diff --git a/etc/schema.Pg b/etc/schema.Pg
index c86a710342..fe69bfd9f3 100644
--- a/etc/schema.Pg
+++ b/etc/schema.Pg
@@ -33,7 +33,7 @@ CREATE TABLE Attachments (
 CREATE INDEX Attachments1 ON Attachments (Parent) ;
 CREATE INDEX Attachments2 ON Attachments (TransactionId) ;
 CREATE INDEX Attachments3 ON Attachments (Parent, TransactionId) ;
-CREATE INDEX Attachments4 ON Attachments (Filename) ;
+CREATE INDEX Attachments4 ON Attachments (LOWER(Filename));
 
 
 
@@ -91,8 +91,8 @@ CREATE TABLE Links (
   PRIMARY KEY (id)
 
 );
-CREATE UNIQUE INDEX Links1 ON Links (Base, Target, Type) ;
-CREATE INDEX Links4 ON Links(Type,LocalBase);
+CREATE UNIQUE INDEX Links1 ON Links (LOWER(Base), LOWER(Target), LOWER(Type));
+CREATE INDEX Links4 ON Links(LOWER(Type), LocalBase);
 
 
 
@@ -202,7 +202,7 @@ CREATE TABLE Transactions (
   PRIMARY KEY (id)
 
 );
-CREATE INDEX Transactions1 ON Transactions (ObjectType, ObjectId);
+CREATE INDEX Transactions1 ON Transactions (LOWER(ObjectType), ObjectId);
 
 
 
@@ -278,7 +278,7 @@ CREATE TABLE ACL (
 
 );
 
-CREATE INDEX  ACL1 on ACL(RightName, ObjectType, ObjectId,PrincipalType,PrincipalId);
+CREATE INDEX ACL1 on ACL(LOWER(RightName), LOWER(ObjectType), ObjectId, LOWER(PrincipalType), PrincipalId);
 
 
 
@@ -514,8 +514,8 @@ CREATE TABLE ObjectCustomFieldValues (
 
 );
 
-CREATE INDEX ObjectCustomFieldValues1 ON ObjectCustomFieldValues (CustomField,ObjectType,ObjectId,Content); 
-CREATE INDEX ObjectCustomFieldValues2 ON ObjectCustomFieldValues (CustomField,ObjectType,ObjectId); 
+CREATE INDEX ObjectCustomFieldValues1 ON ObjectCustomFieldValues (CustomField, LOWER(ObjectType), ObjectId, LOWER(Content));
+CREATE INDEX ObjectCustomFieldValues2 ON ObjectCustomFieldValues (CustomField, LOWER(ObjectType), ObjectId);
 
 
 
@@ -629,8 +629,8 @@ CREATE TABLE Attributes (
 
 );
 
-CREATE INDEX Attributes1 on Attributes(Name);
-CREATE INDEX Attributes2 on Attributes(ObjectType, ObjectId);
+CREATE INDEX Attributes1 on Attributes(LOWER(Name));
+CREATE INDEX Attributes2 on Attributes(LOWER(ObjectType), ObjectId);
 
 
 
diff --git a/etc/upgrade/5.0.3/schema.Pg b/etc/upgrade/5.0.3/schema.Pg
index 01b4a93bb5..d2f6e856d3 100644
--- a/etc/upgrade/5.0.3/schema.Pg
+++ b/etc/upgrade/5.0.3/schema.Pg
@@ -4,3 +4,21 @@ DROP INDEX Tickets1;
 CREATE INDEX Tickets1 ON Tickets (Queue, LOWER(Status));
 DROP INDEX AssetsStatus;
 CREATE INDEX AssetsStatus ON Assets (LOWER(Status));
+DROP INDEX ACL1;
+CREATE INDEX ACL1 on ACL(LOWER(RightName), LOWER(ObjectType), ObjectId, LOWER(PrincipalType), PrincipalId);
+DROP INDEX Attachments4;
+CREATE INDEX Attachments4 ON Attachments (LOWER(Filename));
+DROP INDEX Attributes1;
+CREATE INDEX Attributes1 on Attributes(LOWER(Name));
+DROP INDEX Attributes2;
+CREATE INDEX Attributes2 on Attributes(LOWER(ObjectType), ObjectId);
+DROP INDEX Links1;
+CREATE UNIQUE INDEX Links1 ON Links (LOWER(Base), LOWER(Target), LOWER(Type));
+DROP INDEX Links4;
+CREATE INDEX Links4 ON Links(LOWER(Type), LocalBase);
+DROP INDEX ObjectCUstomFieldValues1;
+CREATE INDEX ObjectCustomFieldValues1 ON ObjectCustomFieldValues (CustomField, LOWER(ObjectType), ObjectId, LOWER(Content));
+DROP INDEX ObjectCUstomFieldValues2;
+CREATE INDEX ObjectCustomFieldValues2 ON ObjectCustomFieldValues (CustomField, LOWER(ObjectType), ObjectId);
+DROP INDEX Transactions1;
+CREATE INDEX Transactions1 ON Transactions (LOWER(ObjectType), ObjectId);

commit d65f4a27b5c320115b8cc1605328b9f5b7d6674e
Author: Brian Conry <bconry at bestpractical.com>
Date:   Wed Mar 30 13:10:45 2022 -0500

    Tickets/Assets Status always use case-insensitive
    
    The code previously  sometimes searched these columns case-sensitive and
    sometimes case-insensitive.  Both Oracle and Pg have case-sensitive
    semantics, so sometimes the indexes were usable and sometimes they
    weren't.
    
    This change standardizes all searches using these columns to be
    explicitly case-insensitive.

diff --git a/etc/schema.Oracle b/etc/schema.Oracle
index 324f790d19..0f47aee45e 100644
--- a/etc/schema.Oracle
+++ b/etc/schema.Oracle
@@ -271,7 +271,7 @@ CREATE TABLE Tickets (
         Creator                 NUMBER(11,0) DEFAULT 0 NOT NULL,
         Created                 DATE
 );
-CREATE INDEX Tickets1 ON Tickets (Queue, Status);
+CREATE INDEX Tickets1 ON Tickets (Queue, LOWER(Status));
 CREATE INDEX Tickets2 ON Tickets (Owner);
 CREATE INDEX Tickets6 ON Tickets (EffectiveId, Type);
 
@@ -493,7 +493,7 @@ CREATE TABLE Assets (
 );
 
 CREATE INDEX AssetsName ON Assets (LOWER(Name));
-CREATE INDEX AssetsStatus ON Assets (Status);
+CREATE INDEX AssetsStatus ON Assets (LOWER(Status));
 CREATE INDEX AssetsCatalog ON Assets (Catalog);
 
 CREATE SEQUENCE Catalogs_seq;
diff --git a/etc/schema.Pg b/etc/schema.Pg
index 9f34ec4b0a..c86a710342 100644
--- a/etc/schema.Pg
+++ b/etc/schema.Pg
@@ -429,7 +429,7 @@ CREATE TABLE Tickets (
 
 );
 
-CREATE INDEX Tickets1 ON Tickets (Queue, Status) ;
+CREATE INDEX Tickets1 ON Tickets (Queue, LOWER(Status));
 CREATE INDEX Tickets2 ON Tickets (Owner) ;
 CREATE INDEX Tickets3 ON Tickets (EffectiveId) ;
 
@@ -725,7 +725,7 @@ CREATE TABLE Assets (
 );
 
 CREATE INDEX AssetsName ON Assets (LOWER(Name));
-CREATE INDEX AssetsStatus ON Assets (Status);
+CREATE INDEX AssetsStatus ON Assets (LOWER(Status));
 CREATE INDEX AssetsCatalog ON Assets (Catalog);
 
 CREATE SEQUENCE catalogs_id_seq;
diff --git a/etc/upgrade/5.0.3/schema.Oracle b/etc/upgrade/5.0.3/schema.Oracle
new file mode 100644
index 0000000000..2d76c9de8b
--- /dev/null
+++ b/etc/upgrade/5.0.3/schema.Oracle
@@ -0,0 +1,4 @@
+DROP INDEX Tickets1;
+CREATE INDEX Tickets1 ON Tickets (Queue, LOWER(Status));
+DROP INDEX AssetsStatus;
+CREATE INDEX AssetsStatus ON Assets (LOWER(Status));
diff --git a/etc/upgrade/5.0.3/schema.Pg b/etc/upgrade/5.0.3/schema.Pg
index 628b446a75..01b4a93bb5 100644
--- a/etc/upgrade/5.0.3/schema.Pg
+++ b/etc/upgrade/5.0.3/schema.Pg
@@ -1,2 +1,6 @@
 DROP INDEX Users4;
 CREATE INDEX Users4 ON Users (LOWER(EmailAddress));
+DROP INDEX Tickets1;
+CREATE INDEX Tickets1 ON Tickets (Queue, LOWER(Status));
+DROP INDEX AssetsStatus;
+CREATE INDEX AssetsStatus ON Assets (LOWER(Status));
diff --git a/lib/RT/Assets.pm b/lib/RT/Assets.pm
index dad7d054ca..7ffa5afb64 100644
--- a/lib/RT/Assets.pm
+++ b/lib/RT/Assets.pm
@@ -317,6 +317,9 @@ sub Limit {
     $self->{_sql_looking_at}{ lc $args{FIELD} } = 1
         if $args{FIELD} and (not $args{ALIAS} or $args{ALIAS} eq "main");
 
+    $args{CASESENSITIVE} = 0
+        if $args{FIELD} and lc $args{FIELD} eq 'status' and (not $args{ALIAS} or $args{ALIAS} eq 'main');
+
     $self->SUPER::Limit(%args);
 }
 
diff --git a/lib/RT/Tickets.pm b/lib/RT/Tickets.pm
index 4ffbd6ab61..0a870df762 100644
--- a/lib/RT/Tickets.pm
+++ b/lib/RT/Tickets.pm
@@ -1649,6 +1649,9 @@ sub Limit {
     $self->{_sql_looking_at}{ lc $args{FIELD} } = 1
         if $args{FIELD} and (not $args{ALIAS} or $args{ALIAS} eq "main");
 
+    $args{CASESENSITIVE} = 0
+        if $args{FIELD} and lc $args{FIELD} eq 'status' and (not $args{ALIAS} or $args{ALIAS} eq 'main');
+
     $self->SUPER::Limit(%args);
 }
 
@@ -1757,10 +1760,11 @@ sub LimitStatus {
         @_
     );
     $self->LimitField(
-        FIELD       => 'Status',
-        VALUE       => $args{'VALUE'},
-        OPERATOR    => $args{'OPERATOR'},
-        DESCRIPTION => join( ' ',
+        FIELD         => 'Status',
+        VALUE         => $args{'VALUE'},
+        OPERATOR      => $args{'OPERATOR'},
+        CASESENSITIVE => 0,
+        DESCRIPTION   => join( ' ',
             $self->loc('Status'), $args{'OPERATOR'},
             $self->loc( $args{'VALUE'} ) ),
     );

-----------------------------------------------------------------------


hooks/post-receive
-- 
rt


More information about the rt-commit mailing list