I have an similar problem to: converting a list of integers into range in python But i have a small difference. I have realtively large mariadb database where i have a table of jobs to be done:
Table:
CREATE TABLE blocks (
block_num INTEGER,
data_state TINYINT,
PRIMARY KEY(block_num));
Every entry for which data_state is Null the block_num has to be processed by a python function.
SELECT block_num FROM blocks
where data_state IS NULL
I have two options how to handle the jobs. One is using one Function which processes one entry and one which can process a bulk of entries, which is considerably faster. The bulk needs to be a range for that to happen. Is there a way in sql to return a list containing the range like in converting a list of integers into range in python ?
If i would do that in python i'd either make very many requests to the database or would need to import the whole table as list into python, which would be very inefficient and slow.
Edit: Each number is unique and all numbers are created by the rule xn=xn+1
List:
Block_num data_state
1 Null
2 Null
3 1
4 Null
5 Null
6 1
7 1
8 1
it could be that the ranges where data_state is NULL is about 100 entries in row.
Min : 1
Max : large (like 1000000)