We have a system where documents are uploaded to a SharePoint library using a web interface. I'm accomplishing this using the client API. Specifically I use SaveBinaryDirect to upload the document, after which a CAML query is used to retrieve the document so that the Metadata columns can be set. The CAML query retrieves the document based on the FileLeafRef field, which is populated with the file name of the document which was uploaded.
The problem is that SharePoint imposes a maximum limit of 5000 items returned from any query so once the document library grows to 5000 items, the CAML query will no longer work. (Even though it only ever returns the single document, it apparently requires a scan of the entire library)
I have already investigated indexing columns but apparently you can't index FileLeafRef, and it seems to be the only field which is populated with the document name immediately upon upload. I have postponed the problem by increasing the item limit from 5000 to 10000, but we're about to run up against this new limit, and people are starting to report intermittent performance problems.
Is there any way to upload documents via the Client API and set their Metadata without running up against the maximum item limit?