I have a select query that will return something like the following table:
start | stop | id
------------------
0 | 100 | 1
1 | 101 | 1
2 | 102 | 1
2 | 102 | 2
5 | 105 | 1
7 | 107 | 2
...
300 | 400 | 1
370 | 470 | 1
450 | 550 | 1
Where stop = start + n; n = 100 in this case.
I would like to combine overlays for each id:
start | stop | id
------------------
0 | 105 | 1
2 | 107 | 2
...
300 | 550 | 1
id 1 does not give 0 - 550, because the beginning of 300 after stopping 105.
There will be hundreds of thousands of records returned by the first request, and n can go up to tens of thousands, so the faster it is processed, the better.
Using PostgreSQL by the way.
source
share