QUERY PLAN
Aggregate (cost=247.24..247.25 rows=1 width=8)
-> Sort (cost=246.28..246.44 rows=64 width=2975)
Sort Key: (CASE c.user_status WHEN 3 THEN 1 WHEN 1 THEN 0 ELSE c.user_status END) DESC, c.updated_at DESC
-> GroupAggregate (cost=243.09..244.36 rows=64 width=2975)
Group Key: c.id
-> Sort (cost=243.09..243.25 rows=64 width=16)
Sort Key: c.id
-> Hash Left Join (cost=80.35..241.17 rows=64 width=16)
Hash Cond: (c.id = cm.contact_id)
-> Nested Loop (cost=0.28..160.74 rows=64 width=16)
-> Index Only Scan using tbl_clients_pkey on tbl_clients client (cost=0.28..8.29 rows=1 width=4)
Index Cond: (id = 982)
-> Seq Scan on tbl_contacts c (cost=0.00..151.80 rows=64 width=20)
Filter: (client_id = 982)
-> Hash (cost=76.52..76.52 rows=284 width=4)
-> Seq Scan on tbl_contact_mobiles cm (cost=0.00..76.52 rows=284 width=4)
Filter: (mp_open_id IS NOT NULL)