| Limit (cost=74272.11..74273.16 rows=15 width=372) |
| -> Result (cost=74272.11..74273.16 rows=15 width=372) |
| -> Sort (cost=74272.11..74272.15 rows=15 width=348) |
| Sort Key: "*SELECT* 1".start_at DESC, "*SELECT* 1".ticket_id DESC |
| -> Nested Loop Left Join (cost=1238.93..74271.82 rows=15 width=348) |
| Join Filter: ((tlc.ticket_id = "*SELECT* 1".ticket_id) AND (tlc.ticket_type = "*SELECT* 1".ticket_type)) |
| -> Nested Loop Left Join (cost=99.97..1390.28 rows=15 width=220) |
| Join Filter: (e.id = "*SELECT* 1".engineer_id) |
| -> Nested Loop Left Join (cost=99.97..1341.08 rows=15 width=211) |
| Join Filter: (sr.id = "*SELECT* 1".sales_rep_id) |
| -> Nested Loop Left Join (cost=99.97..1291.88 rows=15 width=202) |
| -> Nested Loop Left Join (cost=99.69..1191.41 rows=15 width=180) |
| Join Filter: (c.id = "*SELECT* 1".client_id) |
| -> Append (cost=99.42..1182.89 rows=15 width=139) |
| -> Subquery Scan on "*SELECT* 1" (cost=99.42..440.03 rows=3 width=138) |
| -> Nested Loop Left Join (cost=99.42..440.00 rows=3 width=142) |
| -> Hash Right Join (cost=99.14..436.88 rows=3 width=66) |
| Hash Cond: (c_1.id = p_1.case_id) |
| Filter: (COALESCE(p_1.client_id, c_1.client_id) = 101) |
| -> Seq Scan on tbl_cases c_1 (cost=0.00..267.14 rows=8514 width=24) |
| -> Hash (cost=92.38..92.38 rows=541 width=46) |
| -> Seq Scan on tbl_pre_sales p_1 (cost=0.00..92.38 rows=541 width=46) |
| Filter: ((start_at IS NOT NULL) AND (end_at IS NOT NULL) AND (engineer_id IS NOT NULL) AND ((NOT is_draft) OR (is_draft IS NULL)) AND (end_at > start_at)) |
| -> Index Scan using tbl_clients_pkey on tbl_clients cl (cost=0.28..1.02 rows=1 width=8) |
| Index Cond: ((id = COALESCE(p_1.client_id, c_1.client_id)) AND (id = 101)) |
| -> Subquery Scan on "*SELECT* 2" (cost=373.23..742.86 rows=12 width=139) |
| -> Nested Loop Left Join (cost=373.23..742.74 rows=12 width=143) |
| -> Hash Join (cost=372.95..736.95 rows=12 width=67) |
| Hash Cond: (i.case_id = c_2.id) |
| Join Filter: (COALESCE(i.client_id, c_2.client_id) = 101) |
| -> Seq Scan on tbl_implement_records i (cost=0.00..357.85 rows=2340 width=43) |
| Filter: ((arrived_at IS NOT NULL) AND (left_at IS NOT NULL) AND ((NOT is_draft) OR (is_draft IS NULL)) AND (left_at > arrived_at)) |
| -> Hash (cost=267.14..267.14 rows=8465 width=28) |
| -> Seq Scan on tbl_cases c_2 (cost=0.00..267.14 rows=8465 width=28) |
| Filter: (last_engineer IS NOT NULL) |
| -> Index Scan using tbl_clients_pkey on tbl_clients cl_1 (cost=0.28..0.47 rows=1 width=8) |
| Index Cond: ((id = COALESCE(i.client_id, c_2.client_id)) AND (id = 101)) |
| -> Materialize (cost=0.28..8.30 rows=1 width=45) |
| -> Index Scan using tbl_clients_pkey on tbl_clients c (cost=0.28..8.29 rows=1 width=45) |
| Index Cond: (id = 101) |
| -> Index Scan using tbl_projects_pkey on tbl_projects p (cost=0.28..6.70 rows=1 width=26) |
| Index Cond: (id = "*SELECT* 1".project_id) |
| -> Materialize (cost=0.00..17.16 rows=144 width=13) |
| -> Seq Scan on tbl_users sr (cost=0.00..16.44 rows=144 width=13) |
| -> Materialize (cost=0.00..17.16 rows=144 width=13) |
| -> Seq Scan on tbl_users e (cost=0.00..16.44 rows=144 width=13) |
| -> Materialize (cost=1138.96..72806.70 rows=287 width=44) |
| -> Subquery Scan on tlc (cost=1138.96..72805.26 rows=287 width=44) |
| -> GroupAggregate (cost=1138.96..72802.39 rows=287 width=44) |
| Group Key: "*SELECT* 1_1".ticket_id, "*SELECT* 1_1".ticket_type |
| -> Sort (cost=1138.96..1146.13 rows=2868 width=97) |
| Sort Key: "*SELECT* 1_1".ticket_id, "*SELECT* 1_1".ticket_type |
| -> Hash Left Join (cost=52.30..974.25 rows=2868 width=97) |
| Hash Cond: (("*SELECT* 1_1".engineer_id = payroll.user_id) AND ("*SELECT* 1_1".settle_month = payroll.settle_month)) |
| -> Hash Left Join (cost=2.48..909.38 rows=2868 width=69) |
| Hash Cond: ("*SELECT* 1_1".engineer_id = psrr.user_id) |
| -> Append (cost=0.00..893.85 rows=2868 width=52) |
| -> Subquery Scan on "*SELECT* 1_1" (cost=0.00..104.55 rows=541 width=52) |
| -> Seq Scan on tbl_pre_sales p_2 (cost=0.00..99.14 rows=541 width=280) |
| Filter: ((start_at IS NOT NULL) AND (end_at IS NOT NULL) AND (engineer_id IS NOT NULL) AND ((NOT is_draft) OR (is_draft IS NULL)) AND (end_at > start_at)) |
| -> Subquery Scan on "*SELECT* 2_1" (cost=372.95..789.30 rows=2327 width=52) |
| -> Hash Join (cost=372.95..766.03 rows=2327 width=280) |
| Hash Cond: (i_1.case_id = c_3.id) |
| -> Seq Scan on tbl_implement_records i_1 (cost=0.00..357.85 rows=2340 width=28) |
| Filter: ((arrived_at IS NOT NULL) AND (left_at IS NOT NULL) AND ((NOT is_draft) OR (is_draft IS NULL)) AND (left_at > arrived_at)) |
| -> Hash (cost=267.14..267.14 rows=8465 width=12) |
| -> Seq Scan on tbl_cases c_3 (cost=0.00..267.14 rows=8465 width=12) |
| Filter: (last_engineer IS NOT NULL) |
| -> Hash (cost=2.28..2.28 rows=16 width=21) |
| -> Hash Left Join (cost=1.07..2.28 rows=16 width=21) |
| Hash Cond: (psrr.punch_strategy_id = ps.id) |
| -> Seq Scan on tbl_punch_strategy_resource_rels psrr (cost=0.00..1.16 rows=16 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=46.82..46.82 rows=200 width=40) |
| -> Subquery Scan on payroll (cost=42.32..46.82 rows=200 width=40) |
| -> HashAggregate (cost=42.32..44.82 rows=200 width=40) |
| Group Key: am.user_id, t.settle_month |
| -> Append (cost=12.96..40.31 rows=268 width=40) |
| -> HashAggregate (cost=12.96..15.56 rows=208 width=40) |
| Group Key: am.user_id, t.settle_month |
| -> Hash Join (cost=1.31..10.92 rows=271 width=11) |
| Hash Cond: (am.erp_wage_ticket_id = t.id) |
| -> Seq Scan on tbl_erp_wage_ticket_amounts am (cost=0.00..8.45 rows=345 width=11) |
| Filter: (user_id IS NOT NULL) |
| -> Hash (cost=1.18..1.18 rows=11 width=8) |
| -> Seq Scan on tbl_erp_wage_tickets t (cost=0.00..1.18 rows=11 width=8) |
| Filter: (status = 2) |
| -> HashAggregate (cost=9.96..10.28 rows=26 width=40) |
| Group Key: am_1.user_id, t_1.settle_month |
| -> Hash Join (cost=1.14..9.75 rows=27 width=11) |
| Hash Cond: (am_1.erp_social_insurance_id = t_1.id) |
| -> Seq Scan on tbl_erp_social_insurance_amounts am_1 (cost=0.00..7.67 rows=267 width=11) |
| Filter: (user_id IS NOT NULL) |
| -> Hash (cost=1.12..1.12 rows=1 width=8) |
| -> Seq Scan on tbl_erp_social_insurances t_1 (cost=0.00..1.12 rows=1 width=8) |
| Filter: (status = 2) |
| -> HashAggregate (cost=8.24..8.57 rows=26 width=40) |
| Group Key: am_2.user_id, t_2.settle_month |
| -> Hash Join (cost=1.10..8.02 rows=30 width=11) |
| Hash Cond: (am_2.erp_provident_fund_id = t_2.id) |
| -> Seq Scan on tbl_erp_provident_fund_amounts am_2 (cost=0.00..6.11 rows=211 width=11) |
| Filter: (user_id IS NOT NULL) |
| -> Hash (cost=1.09..1.09 rows=1 width=8) |
| -> Seq Scan on tbl_erp_provident_funds t_2 (cost=0.00..1.09 rows=1 width=8) |
| Filter: (status = 2) |
| -> HashAggregate (cost=3.12..3.22 rows=8 width=40) |
| Group Key: am_3.user_id, t_3.settle_month |
| -> Hash Join (cost=1.11..3.06 rows=8 width=14) |
| Hash Cond: (am_3.erp_personal_tax_id = t_3.id) |
| -> Seq Scan on tbl_erp_personal_tax_amounts am_3 (cost=0.00..1.68 rows=68 width=14) |
| Filter: (user_id IS NOT NULL) |
| -> Hash (cost=1.10..1.10 rows=1 width=8) |
| -> Seq Scan on tbl_erp_personal_taxs t_3 (cost=0.00..1.10 rows=1 width=8) |
| Filter: (status = 2) |
| SubPlan 1 |
| -> Aggregate (cost=24.94..24.95 rows=1 width=8) |
| -> Hash Left Join (cost=5.67..23.69 rows=500 width=0) |
| Hash Cond: ((work_dates.work_date)::date = pss.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=4.29..17.10 rows=1000 width=13) |
| Hash Cond: ((work_dates.work_date)::date = lh.edate) |
| -> Function Scan on generate_series work_dates (cost=0.01..10.01 rows=1000 width=8) |
| -> 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) |
| -> Hash (cost=1.36..1.36 rows=1 width=9) |
| -> Seq Scan on tbl_punch_strategy_schedules pss (cost=0.00..1.36 rows=1 width=9) |
| Filter: (punch_strategy_id = ps.id) |