in reply to fast way of working with numerical positions
I have tried doing this within a database using sql and it is very very slow.
makes me think that what you really need is a suitable index over the columns you are searching.