QUERY PLAN
Limit (cost=513.43..513.43 rows=1 width=315)
-> Sort (cost=513.43..513.43 rows=1 width=315)
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=513.40..513.42 rows=1 width=315)
Group Key: s.id, (CASE WHEN (rvr.status = 0) THEN 1 ELSE 0 END)
-> Sort (cost=513.40..513.41 rows=1 width=299)
Sort Key: s.id, (CASE WHEN (rvr.status = 0) THEN 1 ELSE 0 END) DESC
-> Hash Right Join (cost=333.69..513.39 rows=1 width=299)
Hash Cond: (ccr.work_log_id = s.id)
-> Seq Scan on tbl_work_log_carbon_copy_rels ccr (cost=0.00..144.59 rows=9359 width=4)
-> Hash (cost=333.68..333.68 rows=1 width=299)
-> Hash Right Join (cost=176.36..333.68 rows=1 width=299)
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=8)
-> Hash (cost=176.35..176.35 rows=1 width=295)
-> Nested Loop (cost=0.29..176.35 rows=1 width=295)
-> Seq Scan on tbl_work_log_verify_rels rvr2 (cost=0.00..167.52 rows=1 width=4)
Filter: ((user_id IS NOT NULL) AND (user_id = 1015) AND (status = 0))
-> Index Scan using tbl_work_logs_pkey on tbl_work_logs s (cost=0.29..8.31 rows=1 width=295)
Index Cond: (id = rvr2.work_log_id)
Filter: ((NOT is_draft) AND (status = '-1'::smallint))