QUERY PLAN
Limit (cost=1318.27..1318.32 rows=20 width=296)
-> Sort (cost=1318.27..1318.41 rows=55 width=296)
Sort Key: s.is_draft DESC, s.end_at DESC, s.updated_at DESC NULLS LAST, s.created_at DESC
-> Group (cost=1316.12..1316.81 rows=55 width=296)
Group Key: s.id, lin.id, lout.id
-> Sort (cost=1316.12..1316.26 rows=55 width=280)
Sort Key: s.id, lin.id, lout.id
-> Nested Loop Left Join (cost=478.80..1314.53 rows=55 width=280)
-> Nested Loop Left Join (cost=478.51..986.79 rows=55 width=276)
-> Hash Right Join (cost=478.22..659.05 rows=55 width=272)
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,5446,5461,5476}'::integer[])) OR (ccr.user_id = 5064))
-> Seq Scan on tbl_work_log_carbon_copy_rels ccr (cost=0.00..144.59 rows=9359 width=8)
-> Hash (cost=476.92..476.92 rows=104 width=272)
-> Hash Right Join (cost=329.00..476.92 rows=104 width=272)
Hash Cond: (rvr.work_log_id = s.id)
-> Seq Scan on tbl_work_log_verify_rels rvr (cost=0.00..126.52 rows=8152 width=4)
-> Hash (cost=327.70..327.70 rows=104 width=272)
-> Bitmap Heap Scan on tbl_work_logs s (cost=5.10..327.70 rows=104 width=272)
Recheck Cond: (created_by = 1000)
Filter: (NOT is_draft)
-> Bitmap Index Scan on tbl_work_logs_created_by_idx (cost=0.00..5.07 rows=104 width=0)
Index Cond: (created_by = 1000)
-> Index Only Scan using tbl_location_pkey on tbl_location lin (cost=0.29..5.96 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.96 rows=1 width=4)
Index Cond: (id = s.location_out_id)