| Limit (cost=90972.18..90972.28 rows=40 width=936) |
| -> Sort (cost=90972.18..90977.18 rows=1998 width=936) |
| Sort Key: c.updated_at DESC |
| -> Subquery Scan on c (cost=3038.12..90909.03 rows=1998 width=936) |
| -> GroupAggregate (cost=3038.12..90849.09 rows=1998 width=840) |
| Group Key: c_1.id |
| -> Merge Left Join (cost=3038.12..90374.56 rows=1998 width=936) |
| Merge Cond: (c_1.id = scs.client_id) |
| -> Merge Left Join (cost=2930.97..90256.69 rows=1998 width=872) |
| Merge Cond: (c_1.id = esgs.client_id) |
| -> Merge Left Join (cost=2904.55..90224.52 rows=1998 width=840) |
| Merge Cond: (c_1.id = t_13.client_id) |
| -> Merge Left Join (cost=2835.83..90150.45 rows=1998 width=808) |
| Merge Cond: (c_1.id = t_12.client_id) |
| -> Merge Left Join (cost=2834.68..90144.27 rows=1998 width=776) |
| Merge Cond: (c_1.id = "*SELECT* 1".client_id) |
| -> Merge Left Join (cost=1338.17..1426.71 rows=1998 width=768) |
| Merge Cond: (c_1.id = ectt.client_id) |
| -> Merge Left Join (cost=1239.62..1317.57 rows=1998 width=736) |
| Merge Cond: (c_1.id = cpc_1.client_id) |
| -> Merge Left Join (cost=1205.32..1278.14 rows=1998 width=704) |
| Merge Cond: (c_1.id = t_5.client_id) |
| -> Merge Left Join (cost=708.38..776.16 rows=1998 width=672) |
| Merge Cond: (c_1.id = eoi.client_id) |
| -> Merge Left Join (cost=706.81..769.57 rows=1998 width=640) |
| Merge Cond: (c_1.id = c_2.client_id) |
| -> Merge Left Join (cost=532.34..588.53 rows=1998 width=608) |
| Merge Cond: (c_1.id = ect.client_id) |
| -> Merge Left Join (cost=529.44..580.58 rows=1998 width=576) |
| Merge Cond: (c_1.id = t_1.client_id) |
| -> Sort (cost=252.55..257.54 rows=1998 width=568) |
| Sort Key: c_1.id |
| -> Hash Left Join (cost=28.78..143.01 rows=1998 width=568) |
| Hash Cond: (c_1.id = o.client_id) |
| -> Seq Scan on tbl_clients c_1 (cost=0.00..108.98 rows=1998 width=504) |
| -> Hash (cost=27.83..27.83 rows=76 width=68) |
| -> Subquery Scan on o (cost=25.93..27.83 rows=76 width=68) |
| -> HashAggregate (cost=25.93..27.07 rows=76 width=68) |
| Group Key: t.client_id |
| -> Hash Right Join (cost=7.75..21.91 rows=536 width=14) |
| Hash Cond: (eipss.erp_sales_outbound_id = t.id) |
| -> Seq Scan on tbl_erp_inventory_product_spents eipss (cost=0.00..12.65 rows=565 width=14) |
| -> Hash (cost=5.92..5.92 rows=146 width=8) |
| -> Seq Scan on tbl_erp_sales_outbounds t (cost=0.00..5.92 rows=146 width=8) |
| Filter: ((client_id IS NOT NULL) AND (status = 2)) |
| -> GroupAggregate (cost=276.90..298.40 rows=873 width=12) |
| Group Key: t_1.client_id |
| -> Sort (cost=276.90..281.16 rows=1703 width=8) |
| Sort Key: t_1.client_id |
| -> Seq Scan on tbl_projects t_1 (cost=0.00..185.50 rows=1703 width=8) |
| Filter: ((client_id IS NOT NULL) AND (project_status = 3)) |
| -> Sort (cost=2.90..2.91 rows=4 width=36) |
| Sort Key: ect.client_id |
| -> Subquery Scan on ect (cost=2.77..2.86 rows=4 width=36) |
| -> HashAggregate (cost=2.77..2.82 rows=4 width=36) |
| Group Key: t_2.client_id |
| -> Seq Scan on tbl_erp_cost_tickets t_2 (cost=0.00..2.74 rows=6 width=9) |
| Filter: ((client_id IS NOT NULL) AND (status = 2)) |
| -> GroupAggregate (cost=174.47..175.21 rows=37 width=36) |
| Group Key: c_2.client_id |
| -> Sort (cost=174.47..174.56 rows=37 width=9) |
| Sort Key: c_2.client_id |
| -> Hash Join (cost=3.39..173.50 rows=37 width=9) |
| Hash Cond: (c_2.id = t_3.contact_id) |
| -> Seq Scan on tbl_contacts c_2 (cost=0.00..139.88 rows=3420 width=8) |
| Filter: (client_id IS NOT NULL) |
| -> Hash (cost=2.74..2.74 rows=52 width=9) |
| -> Seq Scan on tbl_erp_cost_tickets t_3 (cost=0.00..2.74 rows=52 width=9) |
| Filter: (status = 2) |
| -> Sort (cost=1.57..1.57 rows=2 width=36) |
| Sort Key: eoi.client_id |
| -> Subquery Scan on eoi (cost=1.52..1.56 rows=2 width=36) |
| -> HashAggregate (cost=1.52..1.54 rows=2 width=36) |
| Group Key: t_4.client_id |
| -> Seq Scan on tbl_erp_other_income_tickets t_4 (cost=0.00..1.50 rows=3 width=10) |
| Filter: ((client_id IS NOT NULL) AND (status = 2)) |
| -> GroupAggregate (cost=496.94..496.96 rows=1 width=36) |
| Group Key: t_5.client_id |
| -> Sort (cost=496.94..496.95 rows=1 width=9) |
| Sort Key: t_5.client_id |
| -> Hash Left Join (cost=1.09..496.93 rows=1 width=9) |
| Hash Cond: (t_5.id = cpc.erp_cash_cost_ticket_id) |
| Filter: (cpc.id IS NULL) |
| -> Seq Scan on tbl_erp_cash_cost_tickets t_5 (cost=0.00..470.94 rows=4977 width=13) |
| Filter: ((client_id IS NOT NULL) AND (status = 2)) |
| -> Hash (cost=1.04..1.04 rows=4 width=8) |
| -> Seq Scan on tbl_erp_cash_cost_ticket_client_project_costs cpc (cost=0.00..1.04 rows=4 width=8) |
| -> GroupAggregate (cost=34.30..34.37 rows=3 width=36) |
| Group Key: cpc_1.client_id |
| -> Sort (cost=34.30..34.31 rows=4 width=9) |
| Sort Key: cpc_1.client_id |
| -> Nested Loop (cost=0.29..34.26 rows=4 width=9) |
| -> Seq Scan on tbl_erp_cash_cost_ticket_client_project_costs cpc_1 (cost=0.00..1.04 rows=4 width=13) |
| Filter: (client_id IS NOT NULL) |
| -> Index Scan using tbl_erp_cash_cost_tickets_pkey on tbl_erp_cash_cost_tickets t_6 (cost=0.29..8.30 rows=1 width=4) |
| Index Cond: (id = cpc_1.erp_cash_cost_ticket_id) |
| Filter: (status = 2) |
| -> Sort (cost=98.55..99.48 rows=373 width=36) |
| Sort Key: ectt.client_id |
| -> Subquery Scan on ectt (cost=74.23..82.62 rows=373 width=36) |
| -> HashAggregate (cost=74.23..78.89 rows=373 width=36) |
| Group Key: t_7.client_id |
| -> Seq Scan on tbl_erp_collect_tickets t_7 (cost=0.00..63.45 rows=2155 width=10) |
| Filter: ((client_id IS NOT NULL) AND (status = 2)) |
| -> GroupAggregate (cost=1496.51..88708.06 rows=200 width=12) |
| Group Key: "*SELECT* 1".client_id |
| -> Sort (cost=1496.51..1503.65 rows=2855 width=65) |
| Sort Key: "*SELECT* 1".client_id |
| -> Hash Left Join (cost=163.43..1332.64 rows=2855 width=65) |
| Hash Cond: (("*SELECT* 1".engineer_id = payroll.user_id) AND ("*SELECT* 1".settle_month = payroll.settle_month)) |
| -> Hash Left Join (cost=101.74..1255.97 rows=2855 width=37) |
| Hash Cond: ("*SELECT* 1".engineer_id = psrr.user_id) |
| -> Append (cost=99.26..1237.94 rows=2855 width=24) |
| -> Subquery Scan on "*SELECT* 1" (cost=99.26..448.33 rows=541 width=24) |
| -> Hash Right Join (cost=99.26..442.92 rows=541 width=280) |
| Hash Cond: (c_3.id = p.case_id) |
| Filter: (COALESCE(p.client_id, c_3.client_id) IS NOT NULL) |
| -> Seq Scan on tbl_cases c_3 (cost=0.00..267.41 rows=8541 width=12) |
| -> Hash (cost=92.46..92.46 rows=544 width=28) |
| -> Seq Scan on tbl_pre_sales p (cost=0.00..92.46 rows=544 width=28) |
| Filter: ((start_at IS NOT NULL) AND ((NOT is_draft) OR (is_draft IS NULL)) AND (end_at IS NOT NULL) AND (engineer_id IS NOT NULL) AND (end_at > start_at)) |
| -> Subquery Scan on "*SELECT* 2" (cost=373.53..789.60 rows=2314 width=24) |
| -> Hash Join (cost=373.53..766.46 rows=2314 width=280) |
| Hash Cond: (i.case_id = c_4.id) |
| Join Filter: (COALESCE(i.client_id, c_4.client_id) IS NOT NULL) |
| -> Seq Scan on tbl_implement_records i (cost=0.00..357.86 rows=2340 width=24) |
| Filter: ((arrived_at IS NOT NULL) AND ((NOT is_draft) OR (is_draft IS NULL)) AND (left_at IS NOT NULL) AND (left_at > arrived_at)) |
| -> Hash (cost=267.41..267.41 rows=8490 width=16) |
| -> Seq Scan on tbl_cases c_4 (cost=0.00..267.41 rows=8490 width=16) |
| Filter: (last_engineer IS NOT NULL) |
| -> Hash (cost=2.30..2.30 rows=14 width=21) |
| -> Hash Left Join (cost=1.07..2.30 rows=14 width=21) |
| Hash Cond: (psrr.punch_strategy_id = ps.id) |
| -> Seq Scan on tbl_punch_strategy_resource_rels psrr (cost=0.00..1.14 rows=14 width=8) |
| -> Hash (cost=1.03..1.03 rows=3 width=17) |
| -> Seq Scan on tbl_punch_strategies ps (cost=0.00..1.03 rows=3 width=17) |
| -> Hash (cost=58.69..58.69 rows=200 width=40) |
| -> Subquery Scan on payroll (cost=54.19..58.69 rows=200 width=40) |
| -> HashAggregate (cost=54.19..56.69 rows=200 width=40) |
| Group Key: am.user_id, t_8.settle_month |
| -> Append (cost=12.02..48.96 rows=697 width=40) |
| -> HashAggregate (cost=12.02..14.62 rows=208 width=40) |
| Group Key: am.user_id, t_8.settle_month |
| -> Hash Join (cost=1.34..9.95 rows=276 width=11) |
| Hash Cond: (am.erp_wage_ticket_id = t_8.id) |
| -> Seq Scan on tbl_erp_wage_ticket_amounts am (cost=0.00..7.45 rows=345 width=11) |
| Filter: (user_id IS NOT NULL) |
| -> Hash (cost=1.19..1.19 rows=12 width=8) |
| -> Seq Scan on tbl_erp_wage_tickets t_8 (cost=0.00..1.19 rows=12 width=8) |
| Filter: (status = 2) |
| -> HashAggregate (cost=9.56..12.33 rows=222 width=40) |
| Group Key: am_1.user_id, t_9.settle_month |
| -> Hash Join (cost=1.27..7.89 rows=222 width=11) |
| Hash Cond: (am_1.erp_social_insurance_id = t_9.id) |
| -> Seq Scan on tbl_erp_social_insurance_amounts am_1 (cost=0.00..5.67 rows=267 width=11) |
| Filter: (user_id IS NOT NULL) |
| -> Hash (cost=1.15..1.15 rows=10 width=8) |
| -> Seq Scan on tbl_erp_social_insurances t_9 (cost=0.00..1.15 rows=10 width=8) |
| Filter: (status = 2) |
| -> HashAggregate (cost=7.54..9.82 rows=182 width=40) |
| Group Key: am_2.user_id, t_10.settle_month |
| -> Hash Join (cost=1.21..6.13 rows=188 width=11) |
| Hash Cond: (am_2.erp_provident_fund_id = t_10.id) |
| -> Seq Scan on tbl_erp_provident_fund_amounts am_2 (cost=0.00..4.11 rows=211 width=11) |
| Filter: (user_id IS NOT NULL) |
| -> Hash (cost=1.11..1.11 rows=8 width=8) |
| -> Seq Scan on tbl_erp_provident_funds t_10 (cost=0.00..1.11 rows=8 width=8) |
| Filter: (status = 2) |
| -> HashAggregate (cost=4.16..5.22 rows=85 width=40) |
| Group Key: am_3.user_id, t_11.settle_month |
| -> Hash Join (cost=1.24..3.52 rows=85 width=11) |
| Hash Cond: (am_3.erp_personal_tax_id = t_11.id) |
| -> Seq Scan on tbl_erp_personal_tax_amounts am_3 (cost=0.00..1.94 rows=94 width=11) |
| Filter: (user_id IS NOT NULL) |
| -> Hash (cost=1.12..1.12 rows=9 width=8) |
| -> Seq Scan on tbl_erp_personal_taxs t_11 (cost=0.00..1.12 rows=9 width=8) |
| Filter: (status = 2) |
| SubPlan 1 |
| -> Aggregate (cost=30.50..30.51 rows=1 width=8) |
| -> Hash Left Join (cost=5.78..29.25 rows=500 width=0) |
| Hash Cond: ((work_dates.work_date)::date = lh.edate) |
| Filter: CASE WHEN (ps.id IS NULL) THEN (((date_part('isodow'::text, work_dates.work_date))::integer >= 1) AND ((date_part('isodow'::text, work_dates.work_date))::integer <= 5)) WHEN (pss.id IS NOT NULL) THEN pss.need_work WHEN (ps.legal_holiday AND (lh.id IS NOT NULL)) THEN lh.is_exchange ELSE (((ps.week)::integer & (1 << ((date_part('isodow'::text, work_dates.work_date))::integer - 1))) <> 0) END |
| -> Hash Left Join (cost=1.50..22.00 rows=1000 width=13) |
| Hash Cond: ((work_dates.work_date)::date = pss.edate) |
| -> Function Scan on generate_series work_dates (cost=0.01..10.01 rows=1000 width=8) |
| -> Hash (cost=1.36..1.36 rows=10 width=9) |
| -> Seq Scan on tbl_punch_strategy_schedules pss (cost=0.00..1.36 rows=10 width=9) |
| Filter: (punch_strategy_id = ps.id) |
| -> Hash (cost=2.46..2.46 rows=146 width=9) |
| -> Seq Scan on tbl_legal_holidays lh (cost=0.00..2.46 rows=146 width=9) |
| -> GroupAggregate (cost=1.15..1.17 rows=1 width=36) |
| Group Key: t_12.client_id |
| -> Sort (cost=1.15..1.15 rows=1 width=10) |
| Sort Key: t_12.client_id |
| -> Seq Scan on tbl_erp_cost_convert_tickets t_12 (cost=0.00..1.14 rows=1 width=10) |
| Filter: ((client_id IS NOT NULL) AND (status = 2)) |
| -> GroupAggregate (cost=68.72..68.92 rows=7 width=36) |
| Group Key: t_13.client_id |
| -> Sort (cost=68.72..68.76 rows=15 width=10) |
| Sort Key: t_13.client_id |
| -> Seq Scan on tbl_erp_payment_tickets t_13 (cost=0.00..68.42 rows=15 width=10) |
| Filter: (is_payment_settle AND (client_id IS NOT NULL) AND (status = 2)) |
| -> Sort (cost=26.42..26.54 rows=50 width=36) |
| Sort Key: esgs.client_id |
| -> Subquery Scan on esgs (cost=23.88..25.01 rows=50 width=36) |
| -> HashAggregate (cost=23.88..24.51 rows=50 width=36) |
| Group Key: t_14.client_id |
| -> Hash Right Join (cost=6.03..20.17 rows=495 width=14) |
| Hash Cond: (eipss_1.erp_sales_gift_id = t_14.id) |
| -> Seq Scan on tbl_erp_inventory_product_spents eipss_1 (cost=0.00..12.65 rows=565 width=14) |
| -> Hash (cost=4.61..4.61 rows=113 width=8) |
| -> Seq Scan on tbl_erp_sales_gifts t_14 (cost=0.00..4.61 rows=113 width=8) |
| Filter: ((client_id IS NOT NULL) AND (status = 2)) |
| -> Sort (cost=107.15..108.11 rows=382 width=68) |
| Sort Key: scs.client_id |
| -> Subquery Scan on scs (cost=81.22..90.77 rows=382 width=68) |
| -> HashAggregate (cost=81.22..86.95 rows=382 width=68) |
| Group Key: t_15.client_id |
| -> Seq Scan on tbl_sales_contracts t_15 (cost=0.00..68.32 rows=1720 width=13) |
| Filter: (build_by_project AND (client_id IS NOT NULL)) |