| Aggregate (cost=1183.44..1183.45 rows=1 width=8) |
| -> Sort (cost=1183.22..1183.25 rows=15 width=1766) |
| Sort Key: "*SELECT* 1".start_at DESC, "*SELECT* 1".ticket_id DESC |
| -> Result (cost=99.42..1182.92 rows=15 width=1766) |
| -> Append (cost=99.42..1182.77 rows=15 width=60) |
| -> Subquery Scan on "*SELECT* 1" (cost=99.42..440.01 rows=3 width=60) |
| -> Nested Loop Left Join (cost=99.42..439.98 rows=3 width=280) |
| -> Hash Right Join (cost=99.14..436.88 rows=3 width=28) |
| Hash Cond: (c.id = p.case_id) |
| Filter: (COALESCE(p.client_id, c.client_id) = 101) |
| -> Seq Scan on tbl_cases c (cost=0.00..267.14 rows=8514 width=12) |
| -> Hash (cost=92.38..92.38 rows=541 width=24) |
| -> Seq Scan on tbl_pre_sales p (cost=0.00..92.38 rows=541 width=24) |
| 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.client_id, c.client_id)) AND (id = 101)) |
| -> Subquery Scan on "*SELECT* 2" (cost=373.23..742.77 rows=12 width=60) |
| -> Nested Loop Left Join (cost=373.23..742.65 rows=12 width=280) |
| -> Hash Join (cost=372.95..736.95 rows=12 width=28) |
| Hash Cond: (i.case_id = c_1.id) |
| Join Filter: (COALESCE(i.client_id, c_1.client_id) = 101) |
| -> Seq Scan on tbl_implement_records i (cost=0.00..357.85 rows=2340 width=20) |
| 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=16) |
| -> Seq Scan on tbl_cases c_1 (cost=0.00..267.14 rows=8465 width=16) |
| 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_1.client_id)) AND (id = 101)) |