If you had a fairly large amount of data (say a million rows) that you need returned in a specific order, one obvious way to do this is to simply put a numeric index on each row and order by that index. However, if you then want to create a new row in the middle of that data, you either need to hope that that there is a gap in the index between the two rows you need to put between, or you need to "UPDATE table SET position = position+1 WHERE position > new_position" which is potentially slow and not scalable.
Is there a smarter strategy for dealing with this? Am I best off just leaving large gaps between my rows and hoping for the best (possibly respacing rows with a background process.) Is there a database equivalent to a linked list?
EDIT: I know what indexes are and how traditional ordering is done (read my first sentence.) I'm wondering if there's a data structure to insert a new row into the middle of an ordered index such that range queries can still be done. A traditional next/prev pointer won't work for doing this as a single range query, so far as I know.