Then mmap() won't help, unless you want to use a raw binary file in your computer as a big cache of the database.
mmap() would be the way to go if the data were in a huge binary file instead of a database.
Since you have a database, the ideal would be to read/write large blocks of data and work on them. If there is some transparent way to do this buffering, use it.
Since you are using quicksort, you might want to have two buffers (or sliding windows): one for the lower extreme and one for the upper extreme.
One stupid question: Can't your database sort the data for you?