QUERY PLAN
Limit (cost=370.19..370.20 rows=1 width=285)
-> Sort (cost=370.19..370.20 rows=1 width=285)
Sort Key: c.updated_at DESC
-> HashAggregate (cost=370.17..370.18 rows=1 width=285)
Group Key: c.id
-> Hash Right Join (cost=299.78..367.72 rows=982 width=285)
Hash Cond: (sgr.sales_id = c.deduct_points_from)
-> Seq Scan on tbl_sales_group_relationships sgr (cost=0.00..30.40 rows=2040 width=4)
-> Hash (cost=298.62..298.62 rows=93 width=285)
-> Hash Left Join (cost=209.08..298.62 rows=93 width=285)
Hash Cond: (c.id = cccr.case_id)
Filter: ((c.deduct_points_from = 5493) OR (c.deduct_points_from IS NULL) OR (c.last_engineer = 5495) OR (crr.user_id = 5495) OR (hashed SubPlan 1) OR (cccr.user_id = 5495) OR (c.created_by = 5495))
-> Nested Loop (cost=117.66..196.77 rows=23 width=293)
-> Seq Scan on tbl_engineer_group_relationships egr (cost=0.00..40.60 rows=1 width=4)
Filter: ((engineer_group_id = 1) AND (engineer_id = 5495))
-> Hash Right Join (cost=117.66..155.94 rows=23 width=293)
Hash Cond: (crr.remind_date_id = crd.id)
-> Seq Scan on tbl_case_remind_receivers crr (cost=0.00..30.40 rows=2040 width=8)
-> Hash (cost=117.42..117.42 rows=19 width=293)
-> Hash Right Join (cost=80.26..117.42 rows=19 width=293)
Hash Cond: (crd.case_id = c.id)
-> Seq Scan on tbl_case_remind_dates crd (cost=0.00..26.60 rows=1660 width=8)
-> Hash (cost=80.22..80.22 rows=3 width=289)
-> Nested Loop Left Join (cost=52.22..80.22 rows=3 width=289)
Join Filter: (client.id = c.client_id)
-> Hash Right Join (cost=52.09..72.02 rows=3 width=285)
Hash Cond: (cb.case_id = c.id)
-> Seq Scan on tbl_callback_records cb (cost=0.00..17.20 rows=720 width=4)
-> Hash (cost=52.07..52.07 rows=1 width=285)
-> Hash Right Join (cost=38.76..52.07 rows=1 width=285)
Hash Cond: (ps.case_id = c.id)
-> Seq Scan on tbl_pre_sales ps (cost=0.00..12.40 rows=240 width=4)
-> Hash (cost=38.75..38.75 rows=1 width=285)
-> Hash Right Join (cost=27.09..38.75 rows=1 width=285)
Hash Cond: (iri.implement_record_id = i.id)
-> Seq Scan on tbl_implement_items iri (cost=0.00..11.20 rows=120 width=4)
-> Hash (cost=27.08..27.08 rows=1 width=289)
-> Hash Right Join (cost=13.91..27.08 rows=1 width=289)
Hash Cond: (i.case_id = c.id)
-> Seq Scan on tbl_implement_records i (cost=0.00..12.50 rows=250 width=8)
-> Hash (cost=13.90..13.90 rows=1 width=285)
-> Seq Scan on tbl_cases c (cost=0.00..13.90 rows=1 width=285)
Filter: ((client_id = 1) AND (last_engineer = 5495))
-> Materialize (cost=0.14..8.16 rows=1 width=4)
-> Index Only Scan using tbl_clients_pkey on tbl_clients client (cost=0.14..8.15 rows=1 width=4)
Index Cond: (id = 1)
-> Hash (cost=30.40..30.40 rows=2040 width=8)
-> Seq Scan on tbl_case_carbon_copy_rels cccr (cost=0.00..30.40 rows=2040 width=8)
SubPlan 1
-> Seq Scan on tbl_user_visit_clients (cost=0.00..35.50 rows=10 width=4)
Filter: (user_id = 5495)