QUERY PLAN
Limit (cost=48.07..48.12 rows=20 width=242)
-> Sort (cost=48.07..48.14 rows=29 width=242)
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..47.37 rows=29 width=242)
-> Append (cost=0.00..46.86 rows=29 width=238)
-> Subquery Scan on sub (cost=0.00..0.04 rows=1 width=166)
-> HashAggregate (cost=0.00..0.03 rows=1 width=174)
Group Key: id, status, status
-> Result (cost=0.00..0.00 rows=0 width=91)
One-Time Filter: false
-> Subquery Scan on "*SELECT* 2" (cost=0.00..0.05 rows=1 width=197)
-> HashAggregate (cost=0.00..0.04 rows=1 width=209)
Group Key: id, status, status, status
-> Result (cost=0.00..0.00 rows=0 width=130)
One-Time Filter: false
-> Subquery Scan on "*SELECT* 3" (cost=0.00..0.04 rows=1 width=305)
-> HashAggregate (cost=0.00..0.03 rows=1 width=313)
Group Key: id, status, status
-> Result (cost=0.00..0.00 rows=0 width=230)
One-Time Filter: false
-> Subquery Scan on "*SELECT* 4" (cost=0.00..0.04 rows=1 width=305)
-> HashAggregate (cost=0.00..0.03 rows=1 width=313)
Group Key: id, status, status
-> Result (cost=0.00..0.00 rows=0 width=226)
One-Time Filter: false
-> Subquery Scan on "*SELECT* 5" (cost=45.60..45.64 rows=1 width=210)
-> Group (cost=45.60..45.63 rows=1 width=218)
Group Key: r.id, rvr.status, rsvr.status
-> Sort (cost=45.60..45.60 rows=1 width=131)
Sort Key: r.id, rvr.status, rsvr.status
-> Hash Left Join (cost=23.38..45.59 rows=1 width=131)
Hash Cond: (r.id = rsvr.erp_inventory_overflow_id)
Filter: ((CASE WHEN (1 = r.verify_type) THEN rvr.status ELSE CASE WHEN (r.next_verify_user = 1000) THEN 0 ELSE CASE WHEN (rvr.status = 0) THEN NULL::integer ELSE rvr.status END END END = 1) OR (CASE WHEN (1 = r.verify_type) THEN rsvr.status ELSE CASE WHEN (r.next_stop_verify_user = 1000) THEN 0 ELSE CASE WHEN (rsvr.status = 0) THEN NULL::integer ELSE rsvr.status END END END = 1) OR (CASE WHEN (1 = r.verify_type) THEN rvr.status ELSE CASE WHEN (r.next_verify_user = 1000) THEN 0 ELSE CASE WHEN (rvr.status = 0) THEN NULL::integer ELSE rvr.status END END END = 2) OR (CASE WHEN (1 = r.verify_type) THEN rsvr.status ELSE CASE WHEN (r.next_stop_verify_user = 1000) THEN 0 ELSE CASE WHEN (rsvr.status = 0) THEN NULL::integer ELSE rsvr.status END END END = 2))
-> Hash Right Join (cost=1.19..23.33 rows=7 width=127)
Hash Cond: (rvr.erp_inventory_overflow_id = r.id)
-> Seq Scan on tbl_erp_inventory_overflow_verify_rels rvr (cost=0.00..22.12 rows=5 width=8)
Filter: (user_id = 1000)
-> Hash (cost=1.10..1.10 rows=7 width=123)
-> Seq Scan on tbl_erp_inventory_overflows r (cost=0.00..1.10 rows=7 width=123)
Filter: (status <> 0)
-> Hash (cost=22.12..22.12 rows=5 width=8)
-> Seq Scan on tbl_erp_inventory_overflow_stop_verify_rels rsvr (cost=0.00..22.12 rows=5 width=8)
Filter: (user_id = 1000)
-> Subquery Scan on "*SELECT* 6" (cost=0.00..0.04 rows=1 width=305)
-> HashAggregate (cost=0.00..0.03 rows=1 width=313)
Group Key: id, status, status
-> Result (cost=0.00..0.00 rows=0 width=226)
One-Time Filter: false
-> Subquery Scan on "*SELECT* 7" (cost=0.00..0.04 rows=1 width=305)
-> HashAggregate (cost=0.00..0.03 rows=1 width=313)
Group Key: id, status, status
-> Result (cost=0.00..0.00 rows=0 width=226)
One-Time Filter: false
-> Subquery Scan on "*SELECT* 8" (cost=0.00..0.05 rows=1 width=205)
-> HashAggregate (cost=0.00..0.04 rows=1 width=217)
Group Key: id, status, status, status
-> Result (cost=0.00..0.00 rows=0 width=138)
One-Time Filter: false
-> Subquery Scan on "*SELECT* 9" (cost=0.00..0.04 rows=1 width=214)
-> HashAggregate (cost=0.00..0.03 rows=1 width=222)
Group Key: id, status, status
-> Result (cost=0.00..0.00 rows=0 width=139)
One-Time Filter: false
-> Subquery Scan on "*SELECT* 10" (cost=0.00..0.04 rows=1 width=305)
-> HashAggregate (cost=0.00..0.03 rows=1 width=313)
Group Key: id, status, status
-> Result (cost=0.00..0.00 rows=0 width=230)
One-Time Filter: false
-> Subquery Scan on "*SELECT* 11" (cost=0.00..0.04 rows=1 width=168)
-> HashAggregate (cost=0.00..0.03 rows=1 width=176)
Group Key: id, status, status
-> Result (cost=0.00..0.00 rows=0 width=97)
One-Time Filter: false
-> Subquery Scan on "*SELECT* 12" (cost=0.00..0.04 rows=1 width=195)
-> HashAggregate (cost=0.00..0.03 rows=1 width=203)
Group Key: id, status, status
-> Result (cost=0.00..0.00 rows=0 width=120)
One-Time Filter: false
-> Subquery Scan on "*SELECT* 13" (cost=0.00..0.04 rows=1 width=146)
-> HashAggregate (cost=0.00..0.03 rows=1 width=154)
Group Key: id, status, status
-> Result (cost=0.00..0.00 rows=0 width=115)
One-Time Filter: false
-> Subquery Scan on "*SELECT* 14" (cost=0.00..0.04 rows=1 width=151)
-> HashAggregate (cost=0.00..0.03 rows=1 width=159)
Group Key: id, status, status
-> Result (cost=0.00..0.00 rows=0 width=121)
One-Time Filter: false
-> Subquery Scan on "*SELECT* 15" (cost=0.00..0.04 rows=1 width=170)
-> HashAggregate (cost=0.00..0.03 rows=1 width=178)
Group Key: id, status, status
-> Result (cost=0.00..0.00 rows=0 width=135)
One-Time Filter: false
-> Subquery Scan on "*SELECT* 16" (cost=0.00..0.04 rows=1 width=172)
-> HashAggregate (cost=0.00..0.03 rows=1 width=180)
Group Key: id, status, status
-> Result (cost=0.00..0.00 rows=0 width=141)
One-Time Filter: false
-> Subquery Scan on "*SELECT* 17" (cost=0.00..0.04 rows=1 width=305)
-> HashAggregate (cost=0.00..0.03 rows=1 width=313)
Group Key: id, status, status
-> Result (cost=0.00..0.00 rows=0 width=234)
One-Time Filter: false
-> Subquery Scan on "*SELECT* 18" (cost=0.00..0.04 rows=1 width=305)
-> HashAggregate (cost=0.00..0.03 rows=1 width=313)
Group Key: id, status, status
-> Result (cost=0.00..0.00 rows=0 width=226)
One-Time Filter: false
-> Subquery Scan on "*SELECT* 19" (cost=0.00..0.04 rows=1 width=159)
-> HashAggregate (cost=0.00..0.03 rows=1 width=167)
Group Key: id, status, status
-> Result (cost=0.00..0.00 rows=0 width=121)
One-Time Filter: false
-> Subquery Scan on "*SELECT* 20" (cost=0.00..0.04 rows=1 width=305)
-> HashAggregate (cost=0.00..0.03 rows=1 width=313)
Group Key: id, status, status
-> Result (cost=0.00..0.00 rows=0 width=267)
One-Time Filter: false
-> Subquery Scan on "*SELECT* 21" (cost=0.00..0.04 rows=1 width=159)
-> HashAggregate (cost=0.00..0.03 rows=1 width=167)
Group Key: id, status, status
-> Result (cost=0.00..0.00 rows=0 width=128)
One-Time Filter: false
-> Subquery Scan on "*SELECT* 22" (cost=0.00..0.04 rows=1 width=180)
-> HashAggregate (cost=0.00..0.03 rows=1 width=188)
Group Key: id, status, status
-> Result (cost=0.00..0.00 rows=0 width=149)
One-Time Filter: false
-> Subquery Scan on "*SELECT* 23" (cost=0.00..0.05 rows=1 width=248)
-> HashAggregate (cost=0.00..0.04 rows=1 width=260)
Group Key: id, status, status, status
-> Result (cost=0.00..0.00 rows=0 width=181)
One-Time Filter: false
-> Subquery Scan on "*SELECT* 24" (cost=0.00..0.04 rows=1 width=204)
-> HashAggregate (cost=0.00..0.03 rows=1 width=212)
Group Key: id, status, status
-> Result (cost=0.00..0.00 rows=0 width=158)
One-Time Filter: false
-> Subquery Scan on "*SELECT* 25" (cost=0.00..0.04 rows=1 width=305)
-> HashAggregate (cost=0.00..0.03 rows=1 width=313)
Group Key: id, status, status
-> Result (cost=0.00..0.00 rows=0 width=259)
One-Time Filter: false
-> Subquery Scan on "*SELECT* 26" (cost=0.00..0.04 rows=1 width=305)
-> HashAggregate (cost=0.00..0.03 rows=1 width=313)
Group Key: id, status, status
-> Result (cost=0.00..0.00 rows=0 width=259)
One-Time Filter: false
-> Subquery Scan on "*SELECT* 27" (cost=0.00..0.04 rows=1 width=305)
-> HashAggregate (cost=0.00..0.03 rows=1 width=313)
Group Key: id, status, status
-> Result (cost=0.00..0.00 rows=0 width=259)
One-Time Filter: false
-> Subquery Scan on "*SELECT* 28" (cost=0.00..0.04 rows=1 width=305)
-> HashAggregate (cost=0.00..0.03 rows=1 width=313)
Group Key: id, status, status
-> Result (cost=0.00..0.00 rows=0 width=259)
One-Time Filter: false
-> Subquery Scan on "*SELECT* 29" (cost=0.00..0.05 rows=1 width=305)
-> HashAggregate (cost=0.00..0.04 rows=1 width=313)
Group Key: id, status, status
-> Result (cost=0.00..0.00 rows=0 width=203)
One-Time Filter: false