QUERY PLAN
Aggregate (cost=100.38..100.39 rows=1 width=8)
-> Sort (cost=97.68..98.13 rows=180 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=89.13..90.93 rows=180 width=413)
Group Key: r.id
-> Hash Right Join (cost=56.65..82.61 rows=290 width=30)
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=55.98..55.98 rows=54 width=26)
-> Hash Right Join (cost=32.15..55.98 rows=54 width=26)
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=32.02..32.02 rows=10 width=22)
-> Nested Loop (cost=11.03..32.02 rows=10 width=22)
-> Hash Join (cost=10.89..29.77 rows=10 width=4)
Hash Cond: (ectss.sales_contract_id = s.id)
-> Seq Scan on tbl_erp_collect_ticket_settles ectss (cost=0.00..17.00 rows=700 width=8)
-> Hash (cost=10.88..10.88 rows=1 width=4)
-> Seq Scan on tbl_sales_contracts s (cost=0.00..10.88 rows=1 width=4)
Filter: (project_id = 1)
-> Index Scan using tbl_erp_collect_tickets_pkey on tbl_erp_collect_tickets r (cost=0.14..0.23 rows=1 width=22)
Index Cond: (id = ectss.erp_collect_ticket_id)