QUERY PLAN
Subquery Scan on sub (cost=3.96..4.01 rows=1 width=160)
-> Group (cost=3.96..4.00 rows=1 width=168)
Group Key: r.id, rvr.status, rsvr.status
-> Sort (cost=3.96..3.97 rows=1 width=89)
Sort Key: rvr.status, rsvr.status
-> Nested Loop Left Join (cost=0.00..3.96 rows=1 width=89)
Join Filter: (rsvr.erp_purchase_gift_id = r.id)
-> Nested Loop Left Join (cost=0.00..2.85 rows=1 width=85)
Join Filter: (rvr.erp_purchase_gift_id = r.id)
-> Seq Scan on tbl_erp_purchase_gifts r (cost=0.00..1.30 rows=1 width=81)
Filter: ((status <> 0) AND (id = 22))
-> Seq Scan on tbl_erp_purchase_gift_verify_rels rvr (cost=0.00..1.54 rows=1 width=8)
Filter: ((erp_purchase_gift_id = 22) AND (user_id = 1001))
-> Seq Scan on tbl_erp_purchase_gift_stop_verify_rels rsvr (cost=0.00..1.09 rows=1 width=8)
Filter: ((erp_purchase_gift_id = 22) AND (user_id = 1001))