Using a database will not solve this problem. There are some things a DB can do to make sorting go from O^2 to O^2/n, but this is still exponential growth.
^ Paid post.
Do you understand what "exponential" means? Do you understand how databases work? I'm been working with them for 36 years - you?