I need to copy files from one directory to another, depending on the existence of the file name in a table of SQL database.
For this I use the following code:
<
Allow me to make a guess - Mmmmm... No. There is no way to do it faster.
How come I am so confident? Because file copying requires talking to disk and that is a horribly slow operation. Even further, if you try to go for multi-threading, the results will go slower instead of faster because the 'mechanical' operation of moving the head over the disk isn't sequential anymore, which may have been earlier by chance.
See answers to this question I asked earlier.
So yeah, try going to SSDs if you aren't yet using them, otherwise you are getting the best already.
Below here is something for us to put into perspective what does slow mean in disk writing when compared to caches. If cache access is taking 10 min., it implies that it takes 2 years to read from disk. All the accesses are shown in the image below. Clearly when your code will execute, the bottleneck will be disk writes. The best you can do it to let the disk writes stay sequential.