QUERY PLAN
Aggregate (cost=1248.98..1248.99 rows=1 width=8)
-> Sort (cost=1248.22..1248.35 rows=51 width=175)
Sort Key: s.is_draft DESC, s.end_at DESC, s.updated_at DESC NULLS LAST, s.created_at DESC
-> Group (cost=1246.26..1246.77 rows=51 width=175)
Group Key: s.id, lin.id, lout.id
-> Sort (cost=1246.26..1246.39 rows=51 width=37)
Sort Key: s.id, lin.id, lout.id
-> Nested Loop Left Join (cost=454.90..1244.82 rows=51 width=37)
-> Nested Loop Left Join (cost=454.62..939.91 rows=51 width=37)
-> Hash Right Join (cost=454.33..635.01 rows=51 width=37)
Hash Cond: (ccr.work_log_id = s.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,5388,5446,5449}'::integer[])) OR (ccr.user_id = 5016))
-> Seq Scan on tbl_work_log_carbon_copy_rels ccr (cost=0.00..144.51 rows=9351 width=8)
-> Hash (cost=453.10..453.10 rows=98 width=41)
-> Hash Right Join (cost=310.90..453.10 rows=98 width=41)
Hash Cond: (rvr.work_log_id = s.id)
-> Seq Scan on tbl_work_log_verify_rels rvr (cost=0.00..121.58 rows=7858 width=4)
-> Hash (cost=309.67..309.67 rows=98 width=49)
-> Bitmap Heap Scan on tbl_work_logs s (cost=5.05..309.67 rows=98 width=49)
Recheck Cond: (created_by = 5016)
Filter: (NOT is_draft)
-> Bitmap Index Scan on tbl_work_logs_created_by_idx (cost=0.00..5.03 rows=98 width=0)
Index Cond: (created_by = 5016)
-> Index Only Scan using tbl_location_pkey on tbl_location lin (cost=0.29..5.98 rows=1 width=4)
Index Cond: (id = s.location_in_id)
-> Index Only Scan using tbl_location_pkey on tbl_location lout (cost=0.29..5.98 rows=1 width=4)
Index Cond: (id = s.location_out_id)