Answer the question
In order to leave comments, you need to log in
Will such a distribution of files by its id work?
Good afternoon. This is no longer a question, but so, to consult.
For some time I was thinking about the distribution of files by their id, and settled on this option:
1. Convert id from decimal to hexadecimal. The ID must be greater than or equal to 4096 for the resulting hexadecimal number to be greater than or equal to 4 in length.
2. The store consists of levels. Each level has 256 folders. As a result, 256^2 = 65536 folders. If we take a thousand files as the maximum optimal number of files in a folder, then in the end we have a storage for 65536000 files (1000 in each folder). For the name of the folder of the first level, "cut off" the last 2 digits of id, for the second level, 2 more last digits. In this way we will achieve an even distribution. Here is an example of a path definition:
$dir = substr($hex, -2, 2) . '/' . substr($hex, -4, 2);
Answer the question
In order to leave comments, you need to log in
I would stage
replaced the hash from id or some other value with MD5.
That would decide
and
And so, as for me, it seems normal
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question