QUERY PLAN
Aggregate (cost=488.31..488.32 rows=1 width=8)
-> Sort (cost=488.29..488.29 rows=1 width=171)
Sort Key: s.is_draft DESC, (CASE WHEN (rvr.status = 0) THEN 1 ELSE 0 END) DESC, s.end_at, s.updated_at
-> Group (cost=488.27..488.28 rows=1 width=171)
Group Key: s.id, (CASE WHEN (rvr.status = 0) THEN 1 ELSE 0 END)
-> Sort (cost=488.27..488.27 rows=1 width=25)
Sort Key: s.id, (CASE WHEN (rvr.status = 0) THEN 1 ELSE 0 END) DESC
-> Hash Right Join (cost=308.90..488.26 rows=1 width=25)
Hash Cond: (ccr.work_log_id = s.id)
-> Seq Scan on tbl_work_log_carbon_copy_rels ccr (cost=0.00..144.34 rows=9334 width=4)
-> Hash (cost=308.89..308.89 rows=1 width=25)
-> Hash Right Join (cost=163.63..308.89 rows=1 width=25)
Hash Cond: (rvr.work_log_id = s.id)
-> Seq Scan on tbl_work_log_verify_rels rvr (cost=0.00..116.82 rows=7582 width=8)
-> Hash (cost=163.61..163.61 rows=1 width=21)
-> Nested Loop (cost=0.29..163.61 rows=1 width=21)
-> Seq Scan on tbl_work_log_verify_rels rvr2 (cost=0.00..154.73 rows=1 width=4)
Filter: ((user_id IS NOT NULL) AND (user_id = 1000) AND (status = 0))
-> Index Scan using tbl_work_logs_pkey on tbl_work_logs s (cost=0.29..8.31 rows=1 width=33)
Index Cond: (id = rvr2.work_log_id)
Filter: ((NOT is_draft) AND (status = '-1'::smallint))