QUERY PLAN
Aggregate (cost=644.03..644.04 rows=1 width=8)
-> Sort (cost=644.01..644.02 rows=1 width=167)
Sort Key: s.is_draft DESC, s.end_at DESC, s.updated_at DESC
-> Group (cost=644.00..644.00 rows=1 width=167)
Group Key: s.id
-> Sort (cost=644.00..644.00 rows=1 width=21)
Sort Key: s.id
-> Nested Loop (cost=455.66..643.99 rows=1 width=21)
-> Hash Right Join (cost=455.66..635.82 rows=1 width=25)
Hash Cond: (ccr.work_log_id = s.id)
Filter: ((s.created_by = ANY ('{1015,1015,1022,1023,5248}'::integer[])) OR (ccr.user_id = 1015))
-> Seq Scan on tbl_work_log_carbon_copy_rels ccr (cost=0.00..144.59 rows=9359 width=8)
-> Hash (cost=454.46..454.46 rows=96 width=25)
-> Hash Right Join (cost=306.34..454.46 rows=96 width=25)
Hash Cond: (rvr.work_log_id = s.id)
-> Seq Scan on tbl_work_log_verify_rels rvr (cost=0.00..126.68 rows=8168 width=4)
-> Hash (cost=305.14..305.14 rows=96 width=33)
-> Bitmap Heap Scan on tbl_work_logs s (cost=5.03..305.14 rows=96 width=33)
Recheck Cond: (created_by = 1015)
-> Bitmap Index Scan on tbl_work_logs_created_by_idx (cost=0.00..5.01 rows=96 width=0)
Index Cond: (created_by = 1015)
-> Seq Scan on tbl_users u (cost=0.00..8.16 rows=1 width=4)
Filter: ((id = 1015) AND (department_id = 2))