QUERY PLAN
Sort (cost=176.85..177.20 rows=141 width=21)
Sort Key: (count(c.id)) DESC
-> HashAggregate (cost=170.40..171.81 rows=141 width=21)
Group Key: u.id
-> Hash Join (cost=9.17..153.76 rows=3329 width=17)
Hash Cond: (c.created_by = u.id)
-> Seq Scan on tbl_contacts c (cost=0.00..135.58 rows=3329 width=8)
Filter: ((id IS NOT NULL) AND (client_id IS NOT NULL))
-> Hash (cost=7.41..7.41 rows=141 width=13)
-> Seq Scan on tbl_users u (cost=0.00..7.41 rows=141 width=13)