QUERY PLAN
Subquery Scan on sub (cost=44.70..48.60 rows=1 width=356)
Filter: (sub.id = 1)
-> WindowAgg (cost=44.70..46.97 rows=130 width=356)
-> Sort (cost=44.70..45.02 rows=130 width=348)
Sort Key: sub_1.updated_at DESC
-> Subquery Scan on sub_1 (cost=37.53..40.13 rows=130 width=348)
-> HashAggregate (cost=37.53..38.83 rows=130 width=348)
Group Key: r.id
-> Hash Right Join (cost=14.72..37.21 rows=130 width=348)
Hash Cond: (rvr.erp_inventory_lost_id = r.id)
Filter: ((r.created_by = 1001) OR (rvr.user_id = 1001) OR (r.created_by = ANY ('{1000,1001,1004,1005,1011,1013,1015,1017,1022,1023,5016,5064,5085,5087,5248,5250,5252,5295,5300,5311,5332,5360,5388,5446,5449}'::integer[])))
-> Seq Scan on tbl_erp_inventory_lost_verify_rels rvr (cost=0.00..19.70 rows=970 width=8)
-> Hash (cost=12.10..12.10 rows=210 width=348)
-> Seq Scan on tbl_erp_inventory_losts r (cost=0.00..12.10 rows=210 width=348)