| Unique (cost=120.12..122.13 rows=13 width=539) |
| -> Sort (cost=120.12..120.15 rows=13 width=539) |
| Sort Key: c.name, c.abbr, c.pinyin_shortcut, c.description, c.corp_rep, c.website, c.capital, c.established_at, c.headcount, c.reg_address, c.working_address, c.telephone, c.fax, c.scale, c.branch, c.purchase_scale_per_yr, c.purchase_freq, c.company_nature, c.client_class, c.client_industry, c.client_type, c.sales_rep, c.main_contact, c.created_by, c.created_at, c.updated_at, c.main_business, c.deleted, c.capital_currency, c.invoice_info, c.logo, c.en_name, c.pick_at, c.it_budget, c.deployment_mode, c.it_per_num, c.public_relations_difficulty, c.it_status, c.decision_process, c.coach, c.competitor, c.peers, c.supplier, c.main_product, c.client_base_info_count, c.client_key_info_count, c.contact_count, c.visit_count, c.cooperate_count, c.case_pre_sales_count, c.case_implement_count, c.is_overdue_remind, c.from_contact, c.tax_no, (CASE WHEN (c.sales_rep IS NULL) THEN 0 ELSE c.sales_rep END), (CASE WHEN (c.sales_rep IS NULL) THEN 0 ELSE 1 END), (CASE WHEN (p.id IS NULL) THEN false ELSE true END), ((date_part('epoch'::text, (now() - max(tbl_work_logs_1.end_at))) / '86400'::double precision)), ((date_part('epoch'::text, (now() - max(tbl_work_logs.end_at))) / '86400'::double precision)), (max(tbl_work_logs_1.end_at)), cc.notice_days |
| -> Nested Loop Left Join (cost=13.36..119.88 rows=13 width=539) |
| Join Filter: (tbl_work_logs_1.client_id = c.id) |
| -> Nested Loop Left Join (cost=8.97..66.63 rows=1 width=518) |
| Join Filter: (cc.id = c.client_class) |
| -> Nested Loop Left Join (cost=8.97..65.54 rows=1 width=516) |
| Join Filter: (p.client_id = c.id) |
| -> Nested Loop Left Join (cost=4.68..53.91 rows=1 width=512) |
| Join Filter: (tbl_work_logs.client_id = c.id) |
| -> Index Scan using tbl_clients_pkey on tbl_clients c (cost=0.28..8.29 rows=1 width=504) |
| Index Cond: (id = 146) |
| Filter: (NOT deleted) |
| -> GroupAggregate (cost=4.40..45.59 rows=1 width=12) |
| Group Key: tbl_work_logs.client_id |
| -> Bitmap Heap Scan on tbl_work_logs (cost=4.40..45.57 rows=1 width=12) |
| Recheck Cond: ((client_id IS NOT NULL) AND (client_id = 146)) |
| Filter: ((NOT is_draft) AND (location_in_id IS NOT NULL) AND (location_out_id IS NOT NULL)) |
| -> Bitmap Index Scan on tbl_work_logs_client_id_idx (cost=0.00..4.40 rows=11 width=0) |
| Index Cond: ((client_id IS NOT NULL) AND (client_id = 146)) |
| -> Bitmap Heap Scan on tbl_projects p (cost=4.30..11.62 rows=1 width=8) |
| Recheck Cond: (client_id = 146) |
| Filter: (project_status = 3) |
| -> Bitmap Index Scan on tbl_projects_client_id_idx (cost=0.00..4.29 rows=2 width=0) |
| Index Cond: (client_id = 146) |
| -> Seq Scan on tbl_client_classes cc (cost=0.00..1.04 rows=4 width=6) |
| -> GroupAggregate (cost=4.39..53.09 rows=13 width=20) |
| Group Key: tbl_work_logs_1.client_id |
| -> Bitmap Heap Scan on tbl_work_logs tbl_work_logs_1 (cost=4.39..52.73 rows=13 width=12) |
| Recheck Cond: (client_id = 146) |
| -> Bitmap Index Scan on tbl_work_logs_client_id_idx (cost=0.00..4.39 rows=13 width=0) |
| Index Cond: (client_id = 146) |