QUERY PLAN
Limit (cost=86.43..86.48 rows=20 width=413)
-> Sort (cost=86.43..86.72 rows=116 width=413)
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 = 5495)) THEN 1 WHEN ((rsvr.status = 0) AND (r.next_stop_verify_user = 5495)) THEN 2 ELSE 4 END END)), r.created_at DESC
-> HashAggregate (cost=82.19..83.34 rows=116 width=413)
Group Key: r.id
-> Hash Right Join (cost=55.17..79.58 rows=116 width=417)
Hash Cond: (rsvr.erp_collect_ticket_id = r.id)
-> Seq Scan on tbl_erp_collect_ticket_stop_verify_rels rsvr (cost=0.00..19.70 rows=970 width=8)
-> Hash (cost=54.89..54.89 rows=22 width=413)
-> Hash Right Join (cost=31.36..54.89 rows=22 width=413)
Hash Cond: (rvr.erp_collect_ticket_id = r.id)
-> Seq Scan on tbl_erp_collect_ticket_verify_rels rvr (cost=0.00..19.70 rows=970 width=8)
-> Hash (cost=31.31..31.31 rows=4 width=409)
-> Hash Join (cost=18.80..31.31 rows=4 width=409)
Hash Cond: (r.id = ectss.erp_collect_ticket_id)
-> Seq Scan on tbl_erp_collect_tickets r (cost=0.00..11.80 rows=180 width=409)
-> Hash (cost=18.75..18.75 rows=4 width=4)
-> Seq Scan on tbl_erp_collect_ticket_settles ectss (cost=0.00..18.75 rows=4 width=4)
Filter: (sales_contract_id = 8)