Microsoft technet states that document libraries have a file limit of 30 million items:
In practice, numerous features seem to break once there are more than 5000 items in a Document library - not just in the initial directory listing - but as a recursive total. For example, you may be able to list folders, but setting permissions or deleting files is met with errors.
Are there any configuration options or optimizations that can be used to relax these limits?
A workaround would be to split folders into separate document libraries, but in our case, with over 5 million files, this would result in a minimum of 1000, 5000 file document libraries and likely many more. At that point we're likely shifting the problem into the library view.
A major showstopper is the effect this has on Sharing - a user trying to share a folder with more than 5000 aggregate items simply fails. I'm investigating the effect (if any) the resource throttling suggestion below has on this.