Previously, I use SQLite3 to store the data. I can use single SQL statement to find the missing sequence number.
code sample {sqlfiddle} http://ift.tt/1luKfjp
select start, stop, (stop-start)+1 as counter from (
select m.sequence + 1 as start,
(select min(sequence) - 1 from aiij as x where x.sequence > m.sequence) as stop
from aiij as m
left outer join aiij as r on m.sequence = r.sequence - 1
where r.sequence is null
) as x where stop is not null;
Now, I have to use Redis to store my data. Is there any efficient way to find the missing number?
Aucun commentaire:
Enregistrer un commentaire