It depends on what you want to do with those 10 million files. If you don't need anything to perform a "list" or "browse" like action on the holding directory, but only access individual files by their names, and can predict their names unambiguously, I don't see any problem storing this many files in the same directory.
On the other hand, keep it in mind that most UIs and shells are not designed to handle this situation efficiently so you'd know not to use
rm * but rather
ls | xargs rm to delete everything here.
Note that the number of inodes in a Unix-style file system (e.g. ext4) is not directly relevant to the choice of having a flat or hierarchical directory structure, because no matter in which directory you put the file it will occupy inodes. And actually deeper directory structure has higher overhead on inode consumption. (So IMO the accepted answer misleadingly mentioned inode limit which didn't support that argument.)