I’m studying gridFS and I have a few questions.
1) gridFS automatically indexing files by generated _id. But most of the time I get files by their filename, so should I create index on ‘filename’ by myself?
2) gridFS don’t have folders, just filenames, but I can mimic folders by using filenames with slashes ‘/images/avatars/35.jpg’, right?
3) If I’m indexing on “filename” – is it better in performance terms to use short filenames? I mean – if I use user’s _id which is 24 symbols long + suffixes, for example "/images/avatar_4f1d36b58e42ba3836ed178e_t.jpg", wouldn’t indexing on such long field slow down my system? Would it be better (faster) to use short user’s login instead of _id?
1) I’d very surprised if the filename weren’t indexed. It’s used throughout the API, and I assume that it is indexed.
2) Yes, you can, but there is no real notion of directories implied. Listing files/dirs is a bit more complicated. In other words it’s just a label.
3) Indexes use hashes, or fixed length strings, so a long key is just as easy to index as a long one.