Home  >  Article  >  Backend Development  >  Is it faster to read files in php or database?

Is it faster to read files in php or database?

王林
王林Original
2019-10-15 17:55:203905browse

Is it faster to read files in php or database?

Is it faster for PHP to read files or databases?

1. Directly reading files is more efficient than database query.

2. It can be inferred that the database efficiency will only get worse without testing when writing files and INSERT.

3. If a very small configuration file does not need to use database features, it is more suitable to be accessed in a separate file. There is no need to create a separate data table or record. Large files such as pictures, music, etc. use files. Storage is more convenient, and it is more reasonable to only put index information such as paths or thumbnails in the database.

4. If you only read files in PHP, file_get_contents is more efficient than fopen and fclose.

Recommended tutorial: PHP video tutorial

The above is the detailed content of Is it faster to read files in php or database?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn