| Limit (cost=9599.36..9603.31 rows=20 width=3873) |
| -> Result (cost=9599.36..10626.75 rows=5202 width=3873) |
| -> Sort (cost=9599.36..9612.36 rows=5202 width=3905) |
| Sort Key: (CASE WHEN (c.sales_rep IS NULL) THEN 0 ELSE 1 END) DESC, ((date_part('epoch'::text, (now() - max(tbl_work_logs.end_at))) / '86400'::double precision)) DESC NULLS LAST, c.created_at DESC |
| -> GroupAggregate (cost=9252.85..9460.93 rows=5202 width=3905) |
| Group Key: c.id, cl.id, (CASE WHEN (tbl_projects.client_id IS NULL) THEN false ELSE true END), ((date_part('epoch'::text, (now() - max(tbl_work_logs.end_at))) / '86400'::double precision)), (max(tbl_work_logs.end_at)) |
| -> Sort (cost=9252.85..9265.86 rows=5202 width=3877) |
| Sort Key: c.id, cl.id, (CASE WHEN (tbl_projects.client_id IS NULL) THEN false ELSE true END), ((date_part('epoch'::text, (now() - max(tbl_work_logs.end_at))) / '86400'::double precision)), (max(tbl_work_logs.end_at)) |
| -> Hash Left Join (cost=165.28..251.76 rows=5202 width=3877) |
| Hash Cond: (c.id = ttr.object_id) |
| -> Hash Right Join (cost=148.61..214.81 rows=5202 width=3880) |
| Hash Cond: (car.client_id = c.id) |
| -> Seq Scan on tbl_client_address_rels car (cost=0.00..30.40 rows=2040 width=8) |
| -> Hash (cost=147.98..147.98 rows=51 width=3880) |
| -> Nested Loop Left Join (cost=92.24..147.98 rows=51 width=3880) |
| Join Filter: (arrive.client_id = c.id) |
| -> Nested Loop Left Join (cost=92.24..131.58 rows=51 width=3872) |
| Join Filter: (tbl_projects.client_id = c.id) |
| -> Hash Right Join (cost=80.85..119.41 rows=51 width=3868) |
| Hash Cond: (sgr.sales_id = c.sales_rep) |
| -> Seq Scan on tbl_sales_group_relationships sgr (cost=0.00..30.40 rows=2040 width=4) |
| -> Hash (cost=80.79..80.79 rows=5 width=3868) |
| -> Hash Right Join (cost=67.30..80.79 rows=5 width=3868) |
| Hash Cond: (cl.id = c.client_class) |
| -> Seq Scan on tbl_client_classes cl (cost=0.00..12.50 rows=250 width=44) |
| -> Hash (cost=67.24..67.24 rows=5 width=3824) |
| -> Hash Right Join (cost=62.07..67.24 rows=5 width=3824) |
| Hash Cond: (tbl_work_logs.client_id = c.id) |
| -> HashAggregate (cost=16.19..19.35 rows=158 width=20) |
| Group Key: tbl_work_logs.client_id |
| -> Seq Scan on tbl_work_logs (cost=0.00..14.50 rows=225 width=12) |
| Filter: (NOT is_draft) |
| -> Hash (cost=45.82..45.82 rows=5 width=3808) |
| -> Seq Scan on tbl_clients c (cost=35.52..45.82 rows=5 width=3808) |
| Filter: ((NOT deleted) AND ((sales_rep = 5493) OR (sales_rep IS NULL) OR (hashed SubPlan 1))) |
| SubPlan 1 |
| -> Seq Scan on tbl_user_visit_clients (cost=0.00..35.50 rows=10 width=4) |
| Filter: (user_id = 5495) |
| -> Materialize (cost=11.38..11.41 rows=1 width=4) |
| -> Group (cost=11.38..11.39 rows=1 width=4) |
| Group Key: tbl_projects.client_id |
| -> Sort (cost=11.38..11.39 rows=1 width=4) |
| Sort Key: tbl_projects.client_id |
| -> Seq Scan on tbl_projects (cost=0.00..11.38 rows=1 width=4) |
| Filter: (project_status = 3) |
| -> Materialize (cost=0.00..15.63 rows=1 width=12) |
| -> Seq Scan on tbl_work_logs arrive (cost=0.00..15.62 rows=1 width=12) |
| Filter: ((NOT is_draft) AND (location_in_id IS NOT NULL) AND (location_out_id IS NOT NULL) AND (client_id IS NOT NULL) AND (scenario_id = 1)) |
| -> Hash (cost=16.62..16.62 rows=3 width=4) |
| -> Seq Scan on tbl_term_taxonomy_relationships ttr (cost=0.00..16.62 rows=3 width=4) |
| Filter: (term_id = 14) |