select t1.id – 1 as missing_id from messages t1 left join messages t2 on t2.id = t1.id – 1 where t2.id is null order by missing_id desc
select t1.id – 1 as missing_id from messages t1 left join messages t2 on t2.id = t1.id – 1 where t2.id is null order by missing_id desc