QUERY PLAN
Limit (cost=4073.54..4073.57 rows=11 width=558)
-> Sort (cost=4073.54..4073.57 rows=11 width=558)
Sort Key: p.bargain_date DESC
-> Nested Loop Left Join (cost=3826.25..4073.35 rows=11 width=558)
Join Filter: (tmp3.project_id = p.id)
-> Hash Left Join (cost=3076.33..3285.07 rows=11 width=462)
Hash Cond: (p.id = tmp5.project_id)
-> Hash Left Join (cost=2810.28..3018.99 rows=11 width=430)
Hash Cond: (p.id = tmp2.project_id)
-> Hash Left Join (cost=2082.71..2291.40 rows=11 width=406)
Hash Cond: (p.id = tmp1.project_id)
-> Hash Left Join (cost=1631.02..1839.68 rows=11 width=382)
Hash Cond: (p.id = tmp4.project_id)
-> Seq Scan on tbl_projects p (cost=0.00..208.63 rows=11 width=358)
Filter: ((project_status = 1) AND (created_by = ANY ('{1001,1004,1005,1013,5087,5295,5300,5311,5329,5332,5420}'::integer[])))
-> Hash (cost=1625.36..1625.36 rows=453 width=28)
-> Subquery Scan on tmp4 (cost=1616.30..1625.36 rows=453 width=28)
-> HashAggregate (cost=1616.30..1620.83 rows=453 width=28)
Group Key: wl.project_id
-> Seq Scan on tbl_work_logs wl (cost=0.00..1610.45 rows=585 width=24)
Filter: ((NOT is_draft) AND (location_in_id IS NOT NULL) AND (location_out_id IS NOT NULL) AND (client_id IS NOT NULL))
-> Hash (cost=441.26..441.26 rows=834 width=28)
-> Subquery Scan on tmp1 (cost=424.58..441.26 rows=834 width=28)
-> HashAggregate (cost=424.58..432.92 rows=834 width=28)
Group Key: c.project_id
-> Hash Right Join (cost=102.22..409.38 rows=1520 width=24)
Hash Cond: (c.id = ps.case_id)
-> Seq Scan on tbl_cases c (cost=0.00..235.42 rows=7542 width=8)
-> Hash (cost=83.22..83.22 rows=1520 width=24)
-> Seq Scan on tbl_pre_sales ps (cost=0.00..83.22 rows=1520 width=24)
Filter: (NOT is_draft)
-> Hash (cost=717.14..717.14 rows=834 width=28)
-> Subquery Scan on tmp2 (cost=700.46..717.14 rows=834 width=28)
-> HashAggregate (cost=700.46..708.80 rows=834 width=28)
Group Key: c_1.project_id
-> Hash Left Join (cost=329.70..638.70 rows=6176 width=24)
Hash Cond: (ir.case_id = c_1.id)
-> Seq Scan on tbl_implement_records ir (cost=0.00..292.78 rows=6176 width=24)
Filter: (NOT is_draft)
-> Hash (cost=235.42..235.42 rows=7542 width=8)
-> Seq Scan on tbl_cases c_1 (cost=0.00..235.42 rows=7542 width=8)
-> Hash (cost=257.18..257.18 rows=710 width=36)
-> Subquery Scan on tmp5 (cost=241.20..257.18 rows=710 width=36)
-> HashAggregate (cost=241.20..250.08 rows=710 width=36)
Group Key: r.project_id
-> Seq Scan on tbl_reimbursements r (cost=0.00..207.29 rows=6783 width=9)
Filter: (status = ANY ('{2,3}'::integer[]))
-> Materialize (cost=749.92..755.42 rows=200 width=36)
-> Subquery Scan on tmp3 (cost=749.92..754.42 rows=200 width=36)
-> HashAggregate (cost=749.92..752.42 rows=200 width=36)
Group Key: c_2.project_id
-> HashAggregate (cost=542.52..636.79 rows=7542 width=40)
Group Key: c_2.id
-> Hash Right Join (cost=329.70..504.56 rows=7592 width=16)
Hash Cond: (ca.case_id = c_2.id)
-> Seq Scan on tbl_case_assignments ca (cost=0.00..154.92 rows=7592 width=12)
-> Hash (cost=235.42..235.42 rows=7542 width=8)
-> Seq Scan on tbl_cases c_2 (cost=0.00..235.42 rows=7542 width=8)