QUERY PLAN
Limit (cost=398.18..398.19 rows=3 width=232)
-> Sort (cost=398.18..398.19 rows=3 width=232)
Sort Key: (min(CASE WHEN (1 = r.verify_type) THEN CASE WHEN (rvr.status = 0) THEN 1 WHEN (rsvr.status = 0) THEN 2 ELSE 4 END ELSE CASE WHEN ((rvr.status = 0) AND (r.next_verify_user = 1001)) THEN 1 WHEN ((rsvr.status = 0) AND (r.next_stop_verify_user = 1001)) THEN 2 ELSE 4 END END)), r.created_at DESC
-> GroupAggregate (cost=398.03..398.16 rows=3 width=232)
Group Key: r.id
-> Merge Left Join (cost=398.03..398.06 rows=3 width=236)
Merge Cond: (r.id = rsvr.erp_cash_cost_ticket_id)
-> Sort (cost=396.97..396.98 rows=3 width=232)
Sort Key: r.id
-> Hash Right Join (cost=9.65..396.95 rows=3 width=232)
Hash Cond: (rvr.erp_cash_cost_ticket_id = r.id)
-> Seq Scan on tbl_erp_cash_cost_ticket_verify_rels rvr (cost=0.00..311.92 rows=20092 width=8)
-> Hash (cost=9.64..9.64 rows=1 width=228)
-> Nested Loop (cost=0.28..9.64 rows=1 width=228)
-> Seq Scan on tbl_erp_cash_cost_ticket_purchase_contract_settles eptss (cost=0.00..1.34 rows=1 width=4)
Filter: (purchase_contract_id = 4238)
-> Index Scan using tbl_erp_cash_cost_tickets_pkey on tbl_erp_cash_cost_tickets r (cost=0.28..8.30 rows=1 width=228)
Index Cond: (id = eptss.erp_cash_cost_ticket_id)
-> Sort (cost=1.06..1.06 rows=1 width=8)
Sort Key: rsvr.erp_cash_cost_ticket_id
-> Seq Scan on tbl_erp_cash_cost_ticket_stop_verify_rels rsvr (cost=0.00..1.05 rows=1 width=8)
Filter: (user_id = 1001)