Update: Yes, just opening advanced search also takes a while while. In fact, the same query occupies the database. I made an analysis of the query.
024-10-21 14:29:54 CEST [137134]: [1-1] user=rt5,db=rt5 LOG: duration: 256964.463 ms execute <unnamed>: SELECT DISTINCT main.* FROM Users main CROSS JOIN ACL ACL_3 JOIN Principals Principals_1 ON ( Principals_1.id = main.id ) JOIN CachedGroupMembers CachedGroupMembers_2 ON ( CachedGroupMembers_2.MemberId = Principals_1.id ) JOIN CachedGroupMembers CachedGroupMembers_4 ON ( CachedGroupMembers_4.MemberId = Principals_1.id ) WHERE ((ACL_3.ObjectType = $1) OR (ACL_3.ObjectType = $2 AND ACL_3.ObjectId = $3)) AND (ACL_3.PrincipalId = CachedGroupMembers_4.GroupId) AND (ACL_3.PrincipalType = $4) AND (ACL_3.RightName IN ($5, $6)) AND (CachedGroupMembers_2.Disabled = $7) AND (CachedGroupMembers_2.GroupId = $8) AND (CachedGroupMembers_4.Disabled = $9) AND (Principals_1.Disabled = $10) AND (Principals_1.PrincipalType = $11) AND (Principals_1.id != $12) ORDER BY main.Name ASC
2024-10-21 14:29:54 CEST [137134]: [2-1] user=rt5,db=rt5 LOG: duration: 256964.454 ms plan:
Query Text: SELECT DISTINCT main.* FROM Users main CROSS JOIN ACL ACL_3 JOIN Principals Principals_1 ON ( Principals_1.id = main.id ) JOIN CachedGroupMembers CachedGroupMembers_2 ON ( CachedGroupMembers_2.MemberId = Principals_1.id ) JOIN CachedGroupMembers CachedGroupMembers_4 ON ( CachedGroupMembers_4.MemberId = Principals_1.id ) WHERE ((ACL_3.ObjectType = $1) OR (ACL_3.ObjectType = $2 AND ACL_3.ObjectId = $3)) AND (ACL_3.PrincipalId = CachedGroupMembers_4.GroupId) AND (ACL_3.PrincipalType = $4) AND (ACL_3.RightName IN ($5, $6)) AND (CachedGroupMembers_2.Disabled = $7) AND (CachedGroupMembers_2.GroupId = $8) AND (CachedGroupMembers_4.Disabled = $9) AND (Principals_1.Disabled = $10) AND (Principals_1.PrincipalType = $11) AND (Principals_1.id != $12) ORDER BY main.Name ASC
Query Parameters: $1 = 'RT::Queue', $2 = 'RT::System', $3 = '1', $4 = 'Group', $5 = 'SuperUser', $6 = 'OwnTicket', $7 = '0', $8 = '4', $9 = '0', $10 = '0', $11 = 'User', $12 = '1'
Unique (cost=317.39..317.47 rows=1 width=308) (actual time=256625.761..256963.803 rows=333 loops=1)
-> Sort (cost=317.39..317.40 rows=1 width=308) (actual time=256625.758..256659.524 rows=734773 loops=1)
Sort Key: main.name, main.id, main.password, main.authtoken, main.comments, main.signature, main.emailaddress, main.freeformcontactinfo, main.organization, main.realname, main.nickname, main.lang, main.gecos, main.homephone, main.workphone, main.mobilephone, main.pagerphone, main.address1, main.address2, main.city, main.state, main.zip, main.country, main.timezone, main.smimecertificate, main.creator, main.created, main.lastupdatedby, main.lastupdated
Sort Method: quicksort Memory: 142109kB
-> Nested Loop (cost=2.11..317.38 rows=1 width=308) (actual time=2.143..254991.840 rows=734773 loops=1)
-> Nested Loop (cost=1.69..130.95 rows=2 width=312) (actual time=0.161..218.114 rows=326712 loops=1)
-> Nested Loop (cost=1.27..128.52 rows=1 width=316) (actual time=0.079..5.210 rows=333 loops=1)
-> Merge Join (cost=0.84..90.20 rows=17 width=312) (actual time=0.064..1.984 rows=647 loops=1)
Merge Cond: (main.id = cachedgroupmembers_2.memberid)
-> Index Scan using users_pkey on users main (cost=0.28..70.52 rows=1647 width=308) (actual time=0.020..0.822 rows=1648 loops=1)
-> Index Only Scan using disgroumem on cachedgroupmembers cachedgroupmembers_2 (cost=0.43..14.27 rows=470 width=4) (actual time=0.030..0.384 rows=648 loops=1)
Index Cond: ((groupid = 4) AND (disabled = 0))
Heap Fetches: 155
-> Index Scan using principals_pkey on principals principals_1 (cost=0.42..2.25 rows=1 width=4) (actual time=0.004..0.004 rows=1 loops=647)
Index Cond: (id = main.id)
Filter: ((id <> 1) AND (disabled = 0) AND ((principaltype)::text = 'User'::text))
Rows Removed by Filter: 0
-> Index Only Scan using cachedgroupmembers2 on cachedgroupmembers cachedgroupmembers_4 (cost=0.43..2.09 rows=34 width=8) (actual time=0.017..0.398 rows=981 loops=333)
Index Cond: ((memberid = principals_1.id) AND (disabled = 0))
Heap Fetches: 39601
-> Index Only Scan using acl1 on acl acl_3 (cost=0.42..93.20 rows=2 width=4) (actual time=0.773..0.779 rows=2 loops=326712)
Index Cond: ((rightname = ANY ('{SuperUser,OwnTicket}'::text[])) AND (principaltype = 'Group'::text) AND (principalid = cachedgroupmembers_4.groupid))
Filter: (((objecttype)::text = 'RT::Queue'::text) OR (((objecttype)::text = 'RT::System'::text) AND (objectid = 1)))
Heap Fetches: 804