| Unique (cost=784.26..803.48 rows=124 width=539) |
| -> Sort (cost=784.26..784.57 rows=124 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=15.31..779.95 rows=124 width=539) |
| Join Filter: (tbl_work_logs_1.client_id = c.id) |
| -> Nested Loop Left Join (cost=10.01..382.16 rows=1 width=518) |
| Join Filter: (cc.id = c.client_class) |
| -> Nested Loop Left Join (cost=10.01..381.07 rows=1 width=516) |
| Join Filter: (p.client_id = c.id) |
| -> Nested Loop Left Join (cost=5.67..350.20 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 = 982) |
| Filter: (NOT deleted) |
| -> GroupAggregate (cost=5.39..341.88 rows=1 width=12) |
| Group Key: tbl_work_logs.client_id |
| -> Bitmap Heap Scan on tbl_work_logs (cost=5.39..341.86 rows=1 width=12) |
| Recheck Cond: ((client_id IS NOT NULL) AND (client_id = 982)) |
| 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..5.39 rows=110 width=0) |
| Index Cond: ((client_id IS NOT NULL) AND (client_id = 982)) |
| -> Bitmap Heap Scan on tbl_projects p (cost=4.34..30.82 rows=4 width=8) |
| Recheck Cond: (client_id = 982) |
| Filter: (project_status = 3) |
| -> Bitmap Index Scan on tbl_projects_client_id_idx (cost=0.00..4.34 rows=8 width=0) |
| Index Cond: (client_id = 982) |
| -> Seq Scan on tbl_client_classes cc (cost=0.00..1.04 rows=4 width=6) |
| -> GroupAggregate (cost=5.30..396.52 rows=124 width=20) |
| Group Key: tbl_work_logs_1.client_id |
| -> Bitmap Heap Scan on tbl_work_logs tbl_work_logs_1 (cost=5.30..393.07 rows=130 width=12) |
| Recheck Cond: (client_id = 982) |
| -> Bitmap Index Scan on tbl_work_logs_client_id_idx (cost=0.00..5.26 rows=130 width=0) |
| Index Cond: (client_id = 982) |