| Limit (cost=2119.57..2119.65 rows=30 width=78) |
| -> Sort (cost=2119.57..2119.86 rows=116 width=78) |
| Sort Key: ((date_part('epoch'::text, (now() - max(sl.end_at))) / '86400'::double precision)), c.created_at DESC |
| -> HashAggregate (cost=2113.83..2116.15 rows=116 width=78) |
| Group Key: c.id, CASE WHEN (p.id IS NULL) THEN false ELSE true END |
| -> Hash Right Join (cost=283.12..2103.46 rows=1037 width=70) |
| Hash Cond: (sl.client_id = c.id) |
| -> Seq Scan on tbl_work_logs sl (cost=0.00..1680.24 rows=35024 width=12) |
| -> Hash (cost=282.39..282.39 rows=58 width=65) |
| -> Nested Loop (cost=95.62..282.39 rows=58 width=65) |
| -> Seq Scan on tbl_sales_group_relationships sgr (cost=0.00..1.73 rows=1 width=4) |
| Filter: ((sales_id = 1001) AND (group_id = 1)) |
| -> Hash Right Join (cost=95.62..280.08 rows=58 width=65) |
| Hash Cond: (p.client_id = c.id) |
| -> Seq Scan on tbl_projects p (cost=0.00..180.19 rows=1623 width=8) |
| Filter: (project_status = 3) |
| -> Hash (cost=94.89..94.89 rows=58 width=61) |
| -> Bitmap Heap Scan on tbl_clients c (cost=4.73..94.89 rows=58 width=61) |
| Recheck Cond: (sales_rep = 1001) |
| Filter: (NOT deleted) |
| -> Bitmap Index Scan on tbl_clients_sales_rep_idx (cost=0.00..4.71 rows=58 width=0) |
| Index Cond: (sales_rep = 1001) |