| Aggregate (cost=5825.29..5825.30 rows=1 width=8) |
| -> Sort (cost=5777.86..5785.76 rows=3162 width=3873) |
| Sort Key: (CASE WHEN (c.sales_rep IS NULL) THEN 0 ELSE 1 END) DESC |
| -> HashAggregate (cost=287.92..319.54 rows=3162 width=3873) |
| 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)) |
| -> Hash Left Join (cost=171.91..248.40 rows=3162 width=29) |
| Hash Cond: (c.id = ttr.object_id) |
| -> Hash Right Join (cost=155.25..219.41 rows=3162 width=32) |
| 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=154.86..154.86 rows=31 width=32) |
| -> Nested Loop Left Join (cost=100.41..154.86 rows=31 width=32) |
| Join Filter: (arrive.client_id = c.id) |
| -> Hash Right Join (cost=100.41..138.77 rows=31 width=32) |
| 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=100.37..100.37 rows=3 width=32) |
| -> Hash Left Join (cost=86.89..100.37 rows=3 width=32) |
| Hash Cond: (c.id = tbl_projects.client_id) |
| -> Hash Right Join (cost=75.48..88.95 rows=3 width=28) |
| Hash Cond: (cl.id = c.client_class) |
| -> Seq Scan on tbl_client_classes cl (cost=0.00..12.50 rows=250 width=4) |
| -> Hash (cost=75.44..75.44 rows=3 width=28) |
| -> Hash Right Join (cost=70.27..75.44 rows=3 width=28) |
| 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=54.05..54.05 rows=3 width=12) |
| -> Seq Scan on tbl_clients c (cost=43.70..54.05 rows=3 width=12) |
| Filter: ((NOT deleted) AND ((hashed SubPlan 2) OR (sales_rep IS NULL)) AND ((sales_rep = 5493) OR (sales_rep IS NULL) OR (hashed SubPlan 1))) |
| SubPlan 2 |
| -> Sort (cost=8.17..8.17 rows=1 width=404) |
| Sort Key: tbl_users.pinyin1 NULLS FIRST, tbl_users.namecut1 NULLS FIRST, tbl_users.pinyin2 NULLS FIRST, tbl_users.namecut2 NULLS FIRST, tbl_users.pinyin3 NULLS FIRST, tbl_users.namecut3 NULLS FIRST, tbl_users.pinyin4 NULLS FIRST, tbl_users.namecut4 NULLS FIRST |
| -> Index Scan using tbl_users_pkey on tbl_users (cost=0.14..8.16 rows=1 width=404) |
| Index Cond: (id = 5493) |
| Filter: ((NOT client_lock) AND (user_status = '1'::type_global_user_status)) |
| SubPlan 1 |
| -> Seq Scan on tbl_user_visit_clients (cost=0.00..35.50 rows=10 width=4) |
| Filter: (user_id = 5495) |
| -> Hash (cost=11.40..11.40 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=4) |
| -> Seq Scan on tbl_work_logs arrive (cost=0.00..15.62 rows=1 width=4) |
| 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) |