QUERY PLAN
Limit (cost=55.32..55.39 rows=27 width=241)
-> Sort (cost=55.32..55.39 rows=27 width=241)
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..54.68 rows=27 width=241)
-> Append (cost=0.00..54.21 rows=27 width=236)
-> Subquery Scan on sub (cost=0.00..0.04 rows=1 width=154)
-> HashAggregate (cost=0.00..0.03 rows=1 width=162)
Group Key: id, status, status
-> Result (cost=0.00..0.00 rows=0 width=79)
One-Time Filter: false
-> Subquery Scan on "*SELECT* 2" (cost=0.00..0.05 rows=1 width=189)
-> HashAggregate (cost=0.00..0.04 rows=1 width=201)
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=297)
-> HashAggregate (cost=0.00..0.03 rows=1 width=305)
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=297)
-> HashAggregate (cost=0.00..0.03 rows=1 width=305)
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=297)
-> HashAggregate (cost=0.00..0.03 rows=1 width=305)
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.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* 7" (cost=0.00..0.04 rows=1 width=297)
-> HashAggregate (cost=0.00..0.03 rows=1 width=305)
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=297)
-> HashAggregate (cost=0.00..0.03 rows=1 width=305)
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=297)
-> HashAggregate (cost=0.00..0.03 rows=1 width=305)
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=297)
-> HashAggregate (cost=0.00..0.03 rows=1 width=305)
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=141)
-> HashAggregate (cost=0.00..0.03 rows=1 width=149)
Group Key: id, status, status
-> Result (cost=0.00..0.00 rows=0 width=110)
One-Time Filter: false
-> Subquery Scan on "*SELECT* 12" (cost=0.00..0.04 rows=1 width=140)
-> HashAggregate (cost=0.00..0.03 rows=1 width=148)
Group Key: id, status, status
-> Result (cost=0.00..0.00 rows=0 width=110)
One-Time Filter: false
-> Subquery Scan on "*SELECT* 13" (cost=0.00..0.04 rows=1 width=143)
-> HashAggregate (cost=0.00..0.03 rows=1 width=151)
Group Key: id, status, status
-> Result (cost=0.00..0.00 rows=0 width=104)
One-Time Filter: false
-> Subquery Scan on "*SELECT* 14" (cost=0.00..0.04 rows=1 width=133)
-> HashAggregate (cost=0.00..0.03 rows=1 width=141)
Group Key: id, status, status
-> Result (cost=0.00..0.00 rows=0 width=94)
One-Time Filter: false
-> Subquery Scan on "*SELECT* 15" (cost=0.00..0.04 rows=1 width=210)
-> HashAggregate (cost=0.00..0.03 rows=1 width=218)
Group Key: id, status, status
-> Result (cost=0.00..0.00 rows=0 width=131)
One-Time Filter: false
-> Subquery Scan on "*SELECT* 16" (cost=0.00..0.04 rows=1 width=297)
-> HashAggregate (cost=0.00..0.03 rows=1 width=305)
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=149)
-> HashAggregate (cost=0.00..0.03 rows=1 width=157)
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=297)
-> HashAggregate (cost=0.00..0.03 rows=1 width=305)
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=124)
-> HashAggregate (cost=0.00..0.03 rows=1 width=132)
Group Key: id, status, status
-> Result (cost=0.00..0.00 rows=0 width=93)
One-Time Filter: false
-> Subquery Scan on "*SELECT* 20" (cost=0.00..0.04 rows=1 width=133)
-> HashAggregate (cost=0.00..0.03 rows=1 width=141)
Group Key: id, status, status
-> Result (cost=0.00..0.00 rows=0 width=102)
One-Time Filter: false
-> Subquery Scan on "*SELECT* 21" (cost=0.00..0.05 rows=1 width=297)
-> HashAggregate (cost=0.00..0.04 rows=1 width=309)
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=297)
-> HashAggregate (cost=0.00..0.03 rows=1 width=305)
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=297)
-> HashAggregate (cost=0.00..0.03 rows=1 width=305)
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=297)
-> HashAggregate (cost=0.00..0.03 rows=1 width=305)
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=297)
-> HashAggregate (cost=0.00..0.03 rows=1 width=305)
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=0.00..0.04 rows=1 width=297)
-> HashAggregate (cost=0.00..0.03 rows=1 width=305)
Group Key: id, status, status
-> Result (cost=0.00..0.00 rows=0 width=251)
One-Time Filter: false
-> Subquery Scan on "*SELECT* 27" (cost=53.02..53.08 rows=1 width=215)
-> GroupAggregate (cost=53.02..53.07 rows=1 width=223)
Group Key: r.id, rvr.status, rsvr.status
-> Sort (cost=53.02..53.03 rows=1 width=113)
Sort Key: r.id, rvr.status, rsvr.status
-> Nested Loop Left Join (cost=23.69..53.01 rows=1 width=113)
-> Hash Left Join (cost=23.41..45.60 rows=1 width=112)
Hash Cond: (r.id = rsvr.erp_profit_distribute_id)
Filter: ((rvr.user_id = 1001) OR (rsvr.user_id = 1001))
-> Hash Right Join (cost=1.23..23.36 rows=9 width=112)
Hash Cond: (rvr.erp_profit_distribute_id = r.id)
-> Seq Scan on tbl_erp_profit_distribute_verify_rels rvr (cost=0.00..22.12 rows=5 width=12)
Filter: (user_id = 1001)
-> Hash (cost=1.11..1.11 rows=9 width=104)
-> Seq Scan on tbl_erp_profit_distributes r (cost=0.00..1.11 rows=9 width=104)
Filter: (status <> 0)
-> Hash (cost=22.12..22.12 rows=5 width=12)
-> Seq Scan on tbl_erp_profit_distribute_stop_verify_rels rsvr (cost=0.00..22.12 rows=5 width=12)
Filter: (user_id = 1001)
-> Index Scan using tbl_projects_pkey on tbl_projects p (cost=0.28..7.41 rows=1 width=9)
Index Cond: (r.project_id = id)