QUERY PLAN
Aggregate (cost=62.47..62.48 rows=1 width=8)
-> Sort (cost=62.45..62.46 rows=1 width=414)
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 = 5250)) THEN 1 WHEN ((rsvr.status = 0) AND (r.next_stop_verify_user = 5250)) THEN 2 ELSE 4 END END)), r.created_at DESC
-> GroupAggregate (cost=62.40..62.44 rows=1 width=414)
Group Key: r.id
-> Sort (cost=62.40..62.41 rows=1 width=30)
Sort Key: r.id
-> Nested Loop Left Join (cost=55.58..62.39 rows=1 width=30)
Join Filter: (rsvr.erp_payment_ticket_id = r.id)
-> Hash Right Join (cost=55.58..61.19 rows=1 width=26)
Hash Cond: (rvr.erp_payment_ticket_id = r.id)
-> Seq Scan on tbl_erp_payment_ticket_verify_rels rvr (cost=0.00..4.62 rows=262 width=8)
-> Hash (cost=55.57..55.57 rows=1 width=22)
-> Nested Loop (cost=0.28..55.57 rows=1 width=22)
-> Seq Scan on tbl_erp_payment_ticket_settles eptss (cost=0.00..47.26 rows=1 width=4)
Filter: (purchase_contract_id = 4487)
-> Index Scan using tbl_erp_payment_tickets_pkey on tbl_erp_payment_tickets r (cost=0.28..8.30 rows=1 width=22)
Index Cond: (id = eptss.erp_payment_ticket_id)
-> Seq Scan on tbl_erp_payment_ticket_stop_verify_rels rsvr (cost=0.00..1.09 rows=9 width=8)