explain from qastaging: Limit (cost=145627.02..145627.04 rows=7 width=266) -> Sort (cost=145627.02..145627.27 rows=101 width=266) Sort Key: ((person.name = 'david.wonderly'::text)), person.displayname, person.name -> Subquery Scan person (cost=145622.57..145625.10 rows=101 width=266) -> HashAggregate (cost=145622.57..145623.84 rows=101 width=266) -> Subquery Scan person (cost=145613.74..145616.01 rows=101 width=266) -> HashAggregate (cost=145613.74..145614.75 rows=101 width=755) -> Append (cost=144443.37..145607.42 rows=101 width=755) -> Nested Loop Left Join (cost=144443.37..145182.56 rows=100 width=755) Filter: ((NOT (public.person.teamowner IS NULL)) OR (public.emailaddress.status = 4)) -> Nested Loop (cost=144443.37..145080.28 rows=100 width=755) -> HashAggregate (cost=144443.37..144444.37 rows=100 width=4) -> Limit (cost=144441.87..144442.12 rows=100 width=8) -> Sort (cost=144441.87..144458.39 rows=6608 width=8) Sort Key: public_subquery.rank -> Subquery Scan public_subquery (cost=0.00..144189.32 rows=6608 width=8) -> Append (cost=0.00..144123.24 rows=6608 width=4) -> Subquery Scan "*SELECT* 1" (cost=0.00..6.42 rows=1 width=4) -> Index Scan using person__name__key on person (cost=0.00..6.41 rows=1 width=4) Index Cond: (name = 'david.wonderly'::text) -> Seq Scan on person (cost=0.00..44384.20 rows=5 width=54) Filter: ((fti)::tsvector @@ '''david'' & ''wonder'' | ''davidwond'''::tsquery) -> Subquery Scan "*SELECT* 3" (cost=0.00..1363.76 rows=125 width=4) -> Nested Loop (cost=0.00..1362.51 rows=125 width=4) -> Seq Scan on ircid (cost=0.00..570.19 rows=125 width=4) Filter: (lower(nickname) = 'david.wonderly'::text) -> Index Scan using person_pkey on person (cost=0.00..6.33 rows=1 width=4) Index Cond: (public.person.id = ircid.person) -> Subquery Scan "*SELECT* 4" (cost=578.23..98368.80 rows=6477 width=4) -> Nested Loop (cost=578.23..98304.03 rows=6477 width=4) -> Bitmap Heap Scan on emailaddress (cost=578.23..31482.49 rows=22092 width=4) Filter: ((status = ANY ('{2,4}'::integer[])) AND (lower(email) ~~ 'david.wonderly%%'::text)) -> Bitmap Index Scan on emailaddress__lower_email__key (cost=0.00..572.71 rows=22376 width=0) Index Cond: ((lower(email) >= 'david.wonderly'::text) AND (lower(email) < 'david.wonderlz'::text)) -> Index Scan using person_pkey on person (cost=0.00..3.01 rows=1 width=4) Index Cond: (public.person.id = public.emailaddress.person) -> Index Scan using person_pkey on person (cost=0.00..6.35 rows=1 width=755) Index Cond: (public.person.id = public_subquery.id) Filter: ((public.person.merged IS NULL) AND (public.person.visibility = 1)) -> Index Scan using emailaddress__person__status__idx on emailaddress (cost=0.00..0.95 rows=5 width=8) Index Cond: (public.emailaddress.person = public.person.id) -> Subquery Scan "*SELECT* 2" (cost=423.85..423.86 rows=1 width=805) -> Limit (cost=423.85..423.85 rows=1 width=805) -> Sort (cost=423.85..423.85 rows=1 width=805) Sort Key: (rank((public.person.fti)::tsvector, '''david'' & ''wonder'' | ''davidwond'''::tsquery)) -> Nested Loop (cost=0.00..423.84 rows=1 width=805) -> Index Scan using teamparticipation_person_idx on teamparticipation (cost=0.00..123.43 rows=47 width=4) Index Cond: (person = 3020039) -> Index Scan using person_pkey on person (cost=0.00..6.38 rows=1 width=805) Index Cond: (public.person.id = teamparticipation.team) Filter: ((NOT (public.person.teamowner IS NULL)) AND ((public.person.fti)::tsvector @@ '''david'' & ''wonder'' | ''davidwond'''::tsquery) AND (public.person.visibility = 30)) (51 rows)