-- only query I see that uses Parent field doesn't use index1 or index3.
-- i could have missed something, though.
DROP INDEX Attachments1;
DROP INDEX Attachments3;

-- only query as lower().  seems confusing to allow queues with same
-- name but differing only in case.
DROP INDEX Queues1;
CREATE UNIQUE INDEX Queues1 ON Queues (lower(Name)) ;


-- unable to analyze usage of Links table indexes.

-- when Instance, Type, and Domain are all used it is usually with just plain
-- search so the first index will be used.  this index will cover the search
-- for where type is specified with lower().  Order of fields makes sense
-- from queries I see: sometimes only first one or two are queried.
DROP INDEX Groups2;
CREATE INDEX Groups2 On Groups (lower(Type),lower(Domain),Instance);


-- Transactions table indexes not analyzed.

-- ACL table index not analyzed.  too small to use indexes in my instance

-- group members needs an index!  This one has massive speedups.
CREATE INDEX GroupMembers1 ON GroupMembers (GroupID);


-- I think these are redundant since I only ever see DisGrouMem index used
DROP INDEX CachedgroupMembers2;
DROP INDEX CachedgroupMembers3;



-- the old Users2 is 100% redundant with Users1, and neither gets used
-- since we always query with lower().  Users3 is redundant since "id"
-- is already a PK so if that is queried, we have a unique return.
DROP INDEX Users1;
DROP INDEX Users2;
DROP INDEX Users3;
DROP INDEX Users4;

CREATE UNIQUE INDEX Users1 ON Users (lower(Name)) ;
-- i'm assuming this one needs to be lower() as well; haven't seen it used
CREATE INDEX Users2 ON Users (lower(EmailAddress));

-- redundant indexes.  if "id" is specified, we use PK
DROP INDEX Tickets4;
DROP INDEX Tickets5;
CREATE INDEX Tickets4 ON Tickets (Status);

-- redundant index -- just a prefix of index 1.
DROP INDEX TicketCustomFieldValues2;

-- don't see Attributes used.  looks like an empty table for me.


-- and update the statistics...
ANALYZE;
