Data volume at the same level: which of the following is faster for php to query database files?
Source: Internet
Author: User
Data volume at the same level: ask php to check which file is saved in the database. use the file_exists () function of php to check whether the file exists, this function is faster than querying a record from a database? Premise: if it is a database, a single table has more than 2 million rows of data (the data volume is large and may exceed 10 million). if it is a file, the data volume is also of the same level. & Nbsp; for example, the same level of data volume: ask php to check which file is saved in the database
Ask if the file exists through the file_exists () function of php. Which of the following is faster than querying a record from the database?
Premise: if it is a database, a single table has more than 2 million rows of data (the data volume is large and may exceed 10 million). if it is a file, the data volume is also of the same level.
If function query is used, you only need to know whether the database exists. if the database query is used, select the database;
Thank you for your advice.
------ Solution --------------------
Discussion
Different in nature, not comparable
Effect alone
When the number of files is less than 1024, file_exists is faster than the database
If the number of files you mentioned is greater than 2 million, you can no longer accommodate these files in a directory. No efficiency
------ Solution --------------------
When determining whether a file exists, it is necessary to cyclically judge more paths in these 2 million rows.
Which of the following is
2 million + file_exists vs 2 million + select
The file_exists function is cached. Query Database orm connections, select multiple times
So I tend to select
------ Solution --------------------
As long as you plan the directory structure, there should be no problem.
Note that the file must be organized in a multi-level directory, and the connection in the file needs to be processed.
Not very clear about the linux file system. take windows as an example: files are stored in clusters on the hard disk. no matter how small the files are, they all occupy a cluster (4 KB)
Therefore, your 2 million files require at least 2 MB * 4 K = 8 GB space.
------ Solution --------------------
I don't know what data your data is. In most cases, the data itself is highly variable,
You also need to know how to search.
The database supports a variety of queries and is convenient to delete and modify.
These aspects of files are not good at, not to mention so many files ....
"I think it is like this: html certainly does not consume server resources, so I want to generate all the database files to static files, that is, html files"
If this is your only reason, I basically think it is unnecessary to perform static operations.
The web changes from static html to dynamic technology (such as php), rather than the opposite direction,
Reverse routing generally requires special reasons.
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.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service