Limit (cost=2211.65..2211.72 rows=30 width=78) |
-> Sort (cost=2211.65..2211.94 rows=118 width=78) |
Sort Key: ((date_part('epoch'::text, (now() - max(sl.end_at))) / '86400'::double precision)), c.created_at DESC |
-> HashAggregate (cost=2205.80..2208.16 rows=118 width=78) |
Group Key: c.id, CASE WHEN (p.id IS NULL) THEN false ELSE true END |
-> Hash Right Join (cost=406.55..2195.62 rows=1018 width=70) |
Hash Cond: (sl.client_id = c.id) |
-> Seq Scan on tbl_work_logs sl (cost=0.00..1651.38 rows=34438 width=12) |
-> Hash (cost=405.81..405.81 rows=59 width=65) |
-> Nested Loop Left Join (cost=89.67..405.81 rows=59 width=65) |
Join Filter: (sgr.sales_id = c.sales_rep) |
-> Hash Right Join (cost=89.67..403.31 rows=59 width=65) |
Hash Cond: (p.client_id = c.id) |
-> Seq Scan on tbl_projects p (cost=0.00..309.54 rows=1558 width=8) |
Filter: (project_status = 3) |
-> Hash (cost=88.93..88.93 rows=59 width=61) |
-> Bitmap Heap Scan on tbl_clients c (cost=4.73..88.93 rows=59 width=61) |
Recheck Cond: (sales_rep = 1001) |
Filter: (NOT deleted) |
-> Bitmap Index Scan on tbl_clients_sales_rep_idx (cost=0.00..4.72 rows=59 width=0) |
Index Cond: (sales_rep = 1001) |
-> Materialize (cost=0.00..1.62 rows=1 width=4) |
-> Seq Scan on tbl_sales_group_relationships sgr (cost=0.00..1.61 rows=1 width=4) |
Filter: (sales_id = 1001) |