| Aggregate (cost=249.05..249.06 rows=1 width=32) |
| -> Nested Loop (cost=90.46..249.04 rows=2 width=32) |
| Join Filter: (sub.contract_id = c.id) |
| -> Group (cost=78.20..121.63 rows=2 width=4) |
| Group Key: c.id |
| -> Nested Loop (cost=78.20..121.59 rows=17 width=4) |
| -> Nested Loop (cost=78.05..113.20 rows=17 width=8) |
| Join Filter: (c.id = pcr.contract_id) |
| -> Merge Left Join (cost=34.35..34.42 rows=2 width=4) |
| Merge Cond: (c.id = cs.object_id) |
| -> Sort (cost=1.08..1.09 rows=2 width=8) |
| Sort Key: c.id |
| -> Seq Scan on tbl_purchase_contracts c (cost=0.00..1.07 rows=2 width=8) |
| Filter: ((NOT is_chargeback) AND (NOT is_draft) AND (NOT is_refuse) AND (cost_type = 1)) |
| -> Sort (cost=33.27..33.29 rows=9 width=4) |
| Sort Key: cs.object_id |
| -> Seq Scan on tbl_attachement_relationships cs (cost=0.00..33.12 rows=9 width=4) |
| Filter: (object_type = 108) |
| -> Materialize (cost=43.69..77.38 rows=51 width=8) |
| -> Hash Join (cost=43.69..77.13 rows=51 width=8) |
| Hash Cond: (pcr.client_id = client.id) |
| Join Filter: ((client.sales_rep = ANY ('{5495,5493}'::integer[])) OR (client.sales_rep IS NULL) OR (hashed SubPlan 1) OR (pcr.id IS NULL)) |
| -> Seq Scan on tbl_purchase_client_rels pcr (cost=0.00..28.50 rows=1850 width=12) |
| -> Hash (cost=8.15..8.15 rows=1 width=8) |
| -> Index Scan using tbl_clients_sales_rep_idx on tbl_clients client (cost=0.14..8.15 rows=1 width=8) |
| Index Cond: (sales_rep = 5495) |
| SubPlan 1 |
| -> Seq Scan on tbl_user_visit_clients (cost=0.00..35.50 rows=10 width=4) |
| Filter: (user_id = 5495) |
| -> Materialize (cost=0.15..8.18 rows=1 width=4) |
| -> Index Only Scan using tbl_sales_group_relationships_pkey on tbl_sales_group_relationships sgr (cost=0.15..8.17 rows=1 width=4) |
| Index Cond: ((group_id = 2) AND (sales_id = 5495)) |
| -> Materialize (cost=12.26..126.73 rows=24 width=36) |
| -> Subquery Scan on sub (cost=12.26..126.61 rows=24 width=36) |
| -> Append (cost=12.26..126.37 rows=24 width=124) |
| -> Subquery Scan on "*SELECT* 1" (cost=12.26..31.22 rows=4 width=124) |
| -> Hash Join (cost=12.26..31.17 rows=4 width=120) |
| Hash Cond: (r.erp_payment_ticket_id = t.id) |
| -> Seq Scan on tbl_erp_payment_ticket_settles r (cost=0.00..17.00 rows=700 width=44) |
| -> Hash (cost=12.25..12.25 rows=1 width=52) |
| -> Seq Scan on tbl_erp_payment_tickets t (cost=0.00..12.25 rows=1 width=52) |
| Filter: (is_payment_settle AND (status = ANY ('{2,5}'::integer[]))) |
| -> Hash Join (cost=12.15..31.36 rows=8 width=124) |
| Hash Cond: (r_1.erp_other_income_ticket_id = t_1.id) |
| -> Seq Scan on tbl_erp_other_income_ticket_purchase_contract_settles r_1 (cost=0.00..17.20 rows=720 width=44) |
| -> Hash (cost=12.12..12.12 rows=2 width=48) |
| -> Seq Scan on tbl_erp_other_income_tickets t_1 (cost=0.00..12.12 rows=2 width=48) |
| Filter: (status = ANY ('{2,5}'::integer[])) |
| -> Hash Join (cost=12.39..32.32 rows=4 width=124) |
| Hash Cond: (r_2.erp_cash_cost_ticket_id = t_2.id) |
| -> Seq Scan on tbl_erp_cash_cost_ticket_purchase_contract_settles r_2 (cost=0.00..17.80 rows=780 width=44) |
| -> Hash (cost=12.38..12.38 rows=1 width=48) |
| -> Seq Scan on tbl_erp_cash_cost_tickets t_2 (cost=0.00..12.38 rows=1 width=48) |
| Filter: (is_payment_settle AND (status = ANY ('{2,5}'::integer[]))) |
| -> Hash Join (cost=12.28..31.26 rows=8 width=124) |
| Hash Cond: (r_3.erp_collect_ticket_id = t_3.id) |
| -> Seq Scan on tbl_erp_collect_ticket_settles r_3 (cost=0.00..17.00 rows=700 width=44) |
| -> Hash (cost=12.25..12.25 rows=2 width=48) |
| -> Seq Scan on tbl_erp_collect_tickets t_3 (cost=0.00..12.25 rows=2 width=48) |
| Filter: (status = ANY ('{2,5}'::integer[])) |