QUERY PLAN
Limit (cost=11174.83..11174.88 rows=20 width=321)
-> Sort (cost=11174.83..11240.74 rows=26367 width=321)
Sort Key: s.is_draft DESC, s.end_at DESC, s.updated_at DESC NULLS LAST, s.created_at DESC
-> Group (cost=8390.99..10473.21 rows=26367 width=321)
Group Key: s.id, lin.id, lout.id
-> Gather Merge (cost=8390.99..10290.97 rows=15510 width=305)
Workers Planned: 1
-> Group (cost=7390.98..7546.08 rows=15510 width=305)
Group Key: s.id, lin.id, lout.id
-> Sort (cost=7390.98..7429.76 rows=15510 width=305)
Sort Key: s.id, lin.id, lout.id
-> Hash Left Join (cost=1949.51..4081.92 rows=15510 width=305)
Hash Cond: (s.id = rvr.work_log_id)
-> Hash Left Join (cost=1737.91..3738.43 rows=15510 width=305)
Hash Cond: (s.location_out_id = lout.id)
-> Hash Left Join (cost=999.47..2959.27 rows=15510 width=301)
Hash Cond: (s.location_in_id = lin.id)
-> Hash Left Join (cost=261.01..2180.11 rows=15510 width=297)
Hash Cond: (s.id = ccr.work_log_id)
Filter: ((s.created_by = ANY ('{1000,1001,1004,1005,1011,1013,1015,1017,1022,1023,5016,5064,5085,5087,5248,5250,5252,5295,5296,5300,5311,5329,5332,5360,5388,5404,5420,5440,5445,5446}'::integer[])) OR (ccr.user_id = 1001))
-> Parallel Seq Scan on tbl_work_logs s (cost=0.00..1471.91 rows=19769 width=297)
Filter: (NOT is_draft)
-> Hash (cost=144.34..144.34 rows=9334 width=8)
-> Seq Scan on tbl_work_log_carbon_copy_rels ccr (cost=0.00..144.34 rows=9334 width=8)
-> Hash (cost=503.20..503.20 rows=18820 width=4)
-> Seq Scan on tbl_location lin (cost=0.00..503.20 rows=18820 width=4)
-> Hash (cost=503.20..503.20 rows=18820 width=4)
-> Seq Scan on tbl_location lout (cost=0.00..503.20 rows=18820 width=4)
-> Hash (cost=116.82..116.82 rows=7582 width=4)
-> Seq Scan on tbl_work_log_verify_rels rvr (cost=0.00..116.82 rows=7582 width=4)