QUERY PLAN
Limit (cost=60.80..60.87 rows=26 width=243)
-> Sort (cost=60.80..60.87 rows=26 width=243)
Sort Key: (CASE WHEN ((sub.verify_status = 0) OR (sub.stop_verify_status = 0) OR (sub.cancel_verify_status = 0)) THEN 1 ELSE 2 END), sub.created_at DESC
-> Result (cost=0.00..60.19 rows=26 width=243)
-> Append (cost=0.00..59.74 rows=26 width=239)
-> Subquery Scan on sub (cost=0.00..0.04 rows=1 width=265)
-> HashAggregate (cost=0.00..0.03 rows=1 width=273)
Group Key: id, status, status
-> Result (cost=0.00..0.00 rows=0 width=222)
One-Time Filter: false
-> Subquery Scan on "*SELECT* 2" (cost=0.00..0.04 rows=1 width=157)
-> HashAggregate (cost=0.00..0.03 rows=1 width=169)
Group Key: id, status, status, status
-> Result (cost=0.00..0.00 rows=0 width=122)
One-Time Filter: false
-> Subquery Scan on "*SELECT* 3" (cost=0.00..0.04 rows=1 width=265)
-> HashAggregate (cost=0.00..0.03 rows=1 width=273)
Group Key: id, status, status
-> Result (cost=0.00..0.00 rows=0 width=222)
One-Time Filter: false
-> Subquery Scan on "*SELECT* 4" (cost=0.00..0.04 rows=1 width=265)
-> HashAggregate (cost=0.00..0.03 rows=1 width=273)
Group Key: id, status, status
-> Result (cost=0.00..0.00 rows=0 width=218)
One-Time Filter: false
-> Subquery Scan on "*SELECT* 5" (cost=0.00..0.04 rows=1 width=265)
-> HashAggregate (cost=0.00..0.03 rows=1 width=273)
Group Key: id, status, status
-> Result (cost=0.00..0.00 rows=0 width=218)
One-Time Filter: false
-> Subquery Scan on "*SELECT* 6" (cost=0.00..0.04 rows=1 width=166)
-> HashAggregate (cost=0.00..0.03 rows=1 width=178)
Group Key: id, status, status, status
-> Result (cost=0.00..0.00 rows=0 width=131)
One-Time Filter: false
-> Subquery Scan on "*SELECT* 7" (cost=0.00..0.04 rows=1 width=265)
-> HashAggregate (cost=0.00..0.03 rows=1 width=273)
Group Key: id, status, status
-> Result (cost=0.00..0.00 rows=0 width=222)
One-Time Filter: false
-> Subquery Scan on "*SELECT* 8" (cost=0.00..0.04 rows=1 width=265)
-> HashAggregate (cost=0.00..0.03 rows=1 width=273)
Group Key: id, status, status
-> Result (cost=0.00..0.00 rows=0 width=222)
One-Time Filter: false
-> Subquery Scan on "*SELECT* 9" (cost=0.00..0.04 rows=1 width=265)
-> HashAggregate (cost=0.00..0.03 rows=1 width=273)
Group Key: id, status, status
-> Result (cost=0.00..0.00 rows=0 width=226)
One-Time Filter: false
-> Subquery Scan on "*SELECT* 10" (cost=0.00..0.04 rows=1 width=265)
-> HashAggregate (cost=0.00..0.03 rows=1 width=273)
Group Key: id, status, status
-> Result (cost=0.00..0.00 rows=0 width=226)
One-Time Filter: false
-> Subquery Scan on "*SELECT* 11" (cost=0.00..0.04 rows=1 width=121)
-> HashAggregate (cost=0.00..0.03 rows=1 width=129)
Group Key: id, status, status
-> Result (cost=0.00..0.00 rows=0 width=122)
One-Time Filter: false
-> Subquery Scan on "*SELECT* 12" (cost=0.00..0.04 rows=1 width=88)
-> HashAggregate (cost=0.00..0.03 rows=1 width=96)
Group Key: id, status, status
-> Result (cost=0.00..0.00 rows=0 width=85)
One-Time Filter: false
-> Subquery Scan on "*SELECT* 13" (cost=0.00..0.04 rows=1 width=265)
-> HashAggregate (cost=0.00..0.03 rows=1 width=273)
Group Key: id, status, status
-> Result (cost=0.00..0.00 rows=0 width=258)
One-Time Filter: false
-> Subquery Scan on "*SELECT* 14" (cost=0.00..0.04 rows=1 width=265)
-> HashAggregate (cost=0.00..0.03 rows=1 width=273)
Group Key: id, status, status
-> Result (cost=0.00..0.00 rows=0 width=258)
One-Time Filter: false
-> Subquery Scan on "*SELECT* 15" (cost=0.00..0.04 rows=1 width=265)
-> HashAggregate (cost=0.00..0.03 rows=1 width=273)
Group Key: id, status, status
-> Result (cost=0.00..0.00 rows=0 width=218)
One-Time Filter: false
-> Subquery Scan on "*SELECT* 16" (cost=0.00..0.04 rows=1 width=265)
-> HashAggregate (cost=0.00..0.03 rows=1 width=273)
Group Key: id, status, status
-> Result (cost=0.00..0.00 rows=0 width=218)
One-Time Filter: false
-> Subquery Scan on "*SELECT* 17" (cost=0.00..0.04 rows=1 width=117)
-> HashAggregate (cost=0.00..0.03 rows=1 width=125)
Group Key: id, status, status
-> Result (cost=0.00..0.00 rows=0 width=111)
One-Time Filter: false
-> Subquery Scan on "*SELECT* 18" (cost=0.00..0.04 rows=1 width=265)
-> HashAggregate (cost=0.00..0.03 rows=1 width=273)
Group Key: id, status, status
-> Result (cost=0.00..0.00 rows=0 width=259)
One-Time Filter: false
-> Subquery Scan on "*SELECT* 19" (cost=0.00..0.04 rows=1 width=265)
-> HashAggregate (cost=0.00..0.03 rows=1 width=273)
Group Key: id, status, status
-> Result (cost=0.00..0.00 rows=0 width=262)
One-Time Filter: false
-> Subquery Scan on "*SELECT* 20" (cost=0.00..0.04 rows=1 width=265)
-> HashAggregate (cost=0.00..0.03 rows=1 width=273)
Group Key: id, status, status
-> Result (cost=0.00..0.00 rows=0 width=266)
One-Time Filter: false
-> Subquery Scan on "*SELECT* 21" (cost=0.00..0.04 rows=1 width=265)
-> HashAggregate (cost=0.00..0.03 rows=1 width=277)
Group Key: id, status, status, status
-> Result (cost=0.00..0.00 rows=0 width=230)
One-Time Filter: false
-> Subquery Scan on "*SELECT* 22" (cost=0.00..0.04 rows=1 width=265)
-> HashAggregate (cost=0.00..0.03 rows=1 width=273)
Group Key: id, status, status
-> Result (cost=0.00..0.00 rows=0 width=251)
One-Time Filter: false
-> Subquery Scan on "*SELECT* 23" (cost=0.00..0.04 rows=1 width=265)
-> HashAggregate (cost=0.00..0.03 rows=1 width=273)
Group Key: id, status, status
-> Result (cost=0.00..0.00 rows=0 width=251)
One-Time Filter: false
-> Subquery Scan on "*SELECT* 24" (cost=0.00..0.04 rows=1 width=265)
-> HashAggregate (cost=0.00..0.03 rows=1 width=273)
Group Key: id, status, status
-> Result (cost=0.00..0.00 rows=0 width=251)
One-Time Filter: false
-> Subquery Scan on "*SELECT* 25" (cost=0.00..0.04 rows=1 width=265)
-> HashAggregate (cost=0.00..0.03 rows=1 width=273)
Group Key: id, status, status
-> Result (cost=0.00..0.00 rows=0 width=251)
One-Time Filter: false
-> Subquery Scan on "*SELECT* 26" (cost=58.80..58.84 rows=1 width=265)
-> Group (cost=58.80..58.83 rows=1 width=273)
Group Key: r.id, rvr.status, rsvr.status
-> Sort (cost=58.80..58.81 rows=1 width=251)
Sort Key: r.id, rvr.status, rsvr.status
-> Hash Left Join (cost=44.38..58.79 rows=1 width=251)
Hash Cond: (r.id = rsvr.erp_wage_prize_id)
Filter: (((rvr.user_id = 1001) OR (rsvr.user_id = 1001)) AND ((CASE WHEN (1 = r.verify_type) THEN rvr.status ELSE CASE WHEN (r.next_verify_user = 1001) THEN 0 ELSE CASE WHEN (rvr.status = 0) THEN NULL::integer ELSE rvr.status END END END = 0) OR (CASE WHEN (1 = r.verify_type) THEN rsvr.status ELSE CASE WHEN (r.next_stop_verify_user = 1001) THEN 0 ELSE CASE WHEN (rsvr.status = 0) THEN NULL::integer ELSE rsvr.status END END END = 0)))
-> Hash Left Join (cost=22.19..35.65 rows=209 width=251)
Hash Cond: (r.id = rvr.erp_wage_prize_id)
-> Seq Scan on tbl_erp_wage_prizes r (cost=0.00..12.62 rows=209 width=243)
Filter: (status <> 0)
-> Hash (cost=22.12..22.12 rows=5 width=12)
-> Seq Scan on tbl_erp_wage_prize_verify_rels rvr (cost=0.00..22.12 rows=5 width=12)
Filter: (user_id = 1001)
-> Hash (cost=22.12..22.12 rows=5 width=12)
-> Seq Scan on tbl_erp_wage_prize_stop_verify_rels rsvr (cost=0.00..22.12 rows=5 width=12)
Filter: (user_id = 1001)