QUERY PLAN
Aggregate (cost=85.34..85.35 rows=1 width=8)
-> Sort (cost=85.32..85.33 rows=1 width=175)
Sort Key: s.is_draft DESC, s.end_at DESC, s.updated_at DESC NULLS LAST, s.created_at DESC
-> Group (cost=85.30..85.31 rows=1 width=175)
Group Key: s.id, lin.id, lout.id
-> Sort (cost=85.30..85.31 rows=1 width=37)
Sort Key: s.id, lin.id, lout.id
-> Nested Loop Left Join (cost=45.66..85.29 rows=1 width=37)
-> Nested Loop Left Join (cost=45.51..77.01 rows=1 width=37)
-> Hash Right Join (cost=45.37..68.72 rows=1 width=37)
Hash Cond: (rvr.work_log_id = s.id)
-> Seq Scan on tbl_work_log_verify_rels rvr (cost=0.00..19.70 rows=970 width=4)
-> Hash (cost=45.35..45.35 rows=1 width=37)
-> Hash Right Join (cost=9.52..45.35 rows=1 width=37)
Hash Cond: (ccr.work_log_id = s.id)
Filter: ((s.created_by = ANY ('{5493,5495}'::integer[])) OR (ccr.user_id = 5495))
-> Seq Scan on tbl_work_log_carbon_copy_rels ccr (cost=0.00..30.40 rows=2040 width=8)
-> Hash (cost=9.50..9.50 rows=1 width=49)
-> Bitmap Heap Scan on tbl_work_logs s (cost=4.16..9.50 rows=1 width=49)
Recheck Cond: (created_by = 5495)
Filter: (NOT is_draft)
-> Bitmap Index Scan on tbl_work_logs_created_by_idx (cost=0.00..4.16 rows=2 width=0)
Index Cond: (created_by = 5495)
-> Index Only Scan using tbl_location_pkey on tbl_location lin (cost=0.14..8.16 rows=1 width=4)
Index Cond: (id = s.location_in_id)
-> Index Only Scan using tbl_location_pkey on tbl_location lout (cost=0.14..8.16 rows=1 width=4)
Index Cond: (id = s.location_out_id)