QUERY PLAN
Limit (cost=56.58..56.59 rows=1 width=207)
-> Sort (cost=56.58..56.59 rows=1 width=207)
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=56.54..56.57 rows=1 width=207)
Group Key: r.id
-> Sort (cost=56.54..56.54 rows=1 width=211)
Sort Key: r.id
-> Nested Loop Left Join (cost=52.69..56.53 rows=1 width=211)
Join Filter: (rsvr.erp_payment_ticket_id = r.id)
-> Hash Right Join (cost=52.69..55.32 rows=1 width=207)
Hash Cond: (rvr.erp_payment_ticket_id = r.id)
-> Seq Scan on tbl_erp_payment_ticket_verify_rels rvr (cost=0.00..2.18 rows=118 width=8)
-> Hash (cost=52.68..52.68 rows=1 width=203)
-> Nested Loop (cost=0.28..52.68 rows=1 width=203)
-> Seq Scan on tbl_erp_payment_ticket_settles eptss (cost=0.00..44.38 rows=1 width=4)
Filter: (purchase_contract_id = 4251)
-> Index Scan using tbl_erp_payment_tickets_pkey on tbl_erp_payment_tickets r (cost=0.28..8.30 rows=1 width=203)
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)