QUERY PLAN
Limit (cost=8011.98..8012.03 rows=20 width=296)
-> Sort (cost=8011.98..8059.40 rows=18968 width=296)
Sort Key: s.is_draft DESC, s.end_at DESC, s.updated_at DESC NULLS LAST, s.created_at DESC
-> Group (cost=6009.28..7507.24 rows=18968 width=296)
Group Key: s.id, lin.id, lout.id
-> Gather Merge (cost=6009.28..7376.14 rows=11158 width=280)
Workers Planned: 1
-> Group (cost=5009.27..5120.85 rows=11158 width=280)
Group Key: s.id, lin.id, lout.id
-> Sort (cost=5009.27..5037.17 rows=11158 width=280)
Sort Key: s.id, lin.id, lout.id
-> Hash Left Join (cost=2121.84..4259.13 rows=11158 width=280)
Hash Cond: (s.id = rvr.work_log_id)
-> Hash Left Join (cost=1893.42..3935.52 rows=11158 width=280)
Hash Cond: (s.location_out_id = lout.id)
-> Hash Left Join (cost=1077.50..3090.31 rows=11158 width=276)
Hash Cond: (s.location_in_id = lin.id)
-> Hash Left Join (cost=261.58..2245.10 rows=11158 width=272)
Hash Cond: (s.id = ccr.work_log_id)
Filter: ((s.created_by = ANY ('{1000,1001,1004,1005,1011,1013,1015,1022,1023,5016,5064,5085,5087,5248,5250,5252,5295,5300,5311,5332,5360,5446,5461,5476}'::integer[])) OR (ccr.user_id = 5064))
-> Parallel Seq Scan on tbl_work_logs s (cost=0.00..1566.18 rows=20991 width=272)
Filter: (NOT is_draft)
-> Hash (cost=144.59..144.59 rows=9359 width=8)
-> Seq Scan on tbl_work_log_carbon_copy_rels ccr (cost=0.00..144.59 rows=9359 width=8)
-> Hash (cost=556.52..556.52 rows=20752 width=4)
-> Seq Scan on tbl_location lin (cost=0.00..556.52 rows=20752 width=4)
-> Hash (cost=556.52..556.52 rows=20752 width=4)
-> Seq Scan on tbl_location lout (cost=0.00..556.52 rows=20752 width=4)
-> Hash (cost=126.52..126.52 rows=8152 width=4)
-> Seq Scan on tbl_work_log_verify_rels rvr (cost=0.00..126.52 rows=8152 width=4)