if I were to keep the data in a file in disk and if the data is unsorted, wouldn't it take too long to query what I need from that file?
If you don't save/load everything, but keep everything in an unstructured file on disk, then yes, that is kind-of the slowest of both worlds :-)
If you save/load pieces, then you typically either put each piece in some kind of database. This can be something heavyweight like MySQL or DB/2, or something simple like Berekeley DB or just a file with a table of contents index at the front, or something super-simple like a file per user/entity (with some recursive directory hierarchy to avoid 100,000 files in one directory.)
Also if the memory usage isn't a concern, is it still a bad idea to keep all data in memory?
If the performance is fine (maybe you can save the data asynchronously?) and you have no better use for the RAM, then that's fine.
Another option you may want to consider is memory mapping the file, which makes the file be automatically saved all the time without you having to worry about it.
mmap() on Linux; CreateFileMapping() on Windows.