Data volume at the same level: Ask PHP to check the database which is fast
Ask everybody, through PHP function file_exists () query file exists, this function run speed and query a record from the database compare which is faster?
Premise, if it is a database, single table 2 million rows of data above (the amount of data is large, eventually may be tens of millions), if the file is also the same level of data volume.
If you use a function query, as long as you know whether it exists, if the database query, you need to select out;
Thank you for your guidance.
------Solution--------------------
discuss
Different in nature, not comparable
Only as far as the effect is concerned
When the number of files is less than 1024, file_exists faster than the database
By the number of files you say is greater than 2 million, you cannot fit these files in a directory. There is no efficiency to say
------Solution--------------------
When judging the existence of a file, it is necessary to make a circular judgment on the 2 million-line path.
Right now, the right thing to do is
2 million + file_exists vs 2 million + Select
The File_exists function is cached. Find Database Orm Junction, select multiple times
So I tend to select
------Solution--------------------
As long as you plan the directory structure, there should be no problem
It is important to note that because the files must be organized in a multilevel directory, the connection in the file needs to be handled.
Not very clear about the Linux file system, take the Windows system as an example: Files in the hard disk is clustered, regardless of how small the file, must occupy a cluster (4KB)
Then your 2 million files need at least 2M * 4K = 8G of space
------Solution--------------------
Do not know what your data is exactly what data, in most cases, the data itself is more volatile,
How to retrieve also need to know.
The database supports a variety of queries, and it is also convenient to delete changes.
Files are not good at these aspects, let alone so many documents ....
"I think so: HTML is definitely not consuming server resources, so I want to put the database of all the files generated static files, that is, HTML file"
If this is your only reason, then I am basically determined that this is not necessary for static.
The web is moving from static HTML to dynamic technology (PHP, etc.), not the opposite direction,
It usually takes a special reason to go backwards.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.