Ask php to save the data. thank you!

Source: Internet
Author: User
Ask php to save the data. thank you! My younger brother has a data query website. the expected data volume is very large. I first wanted to insert it into mysql for ease of query, but the actual data volume inserted every day may exceed MB, if you use mysql to estimate the cost increase, you do not know the efficiency.
Therefore, I want to save data in the form of files. I have considered txt and xml, so it is a little difficult to read files. But I recently thought, can I save it as a file through serialization? (Because my data is essentially an array of data.) if all data is serialized and directly deserialized during reading, how efficient should it be?
I want to hear from experts. thank you !!


Reply to discussion (solution)

Should the number of queries read more than the number of writes? No need to use files in the database, IO will consume the machine's

Should the number of queries read more than the number of writes? No need to use files in the database, IO will consume the machine's

Indeed, we have to consider the database ....

Only data that is not frequently changed in the cache is meaningful. Otherwise, the overhead of checking whether the data is updated cannot be ignored.
If your data is only some array data, the most efficient is to save the var_export result to the program file.
You only need to include

It is better to use sqlite as a file with SQL queries.

I don't know what the cost is.
We recommend that you use PostgreSQL, mysql memory database, and maria
For simple document data, nosql, such as couchdb and mongodb can also be considered.


-----------------------------------------------------
In addition, if I/O, performance, and insert concurrency are not considered, you can put the generated PHP file in an array or serialized data with variables.

Try mogonDB. it is very convenient to store serialized data, and the connection with php is also very mature. reading xml and txt is certainly not fast.

Only data that is not frequently changed in the cache is meaningful. Otherwise, the overhead of checking whether the data is updated cannot be ignored.
If your data is only some array data, the most efficient is to save the var_export result to the program file.
You only need to include

The moderator is right. In addition, the var_export result is saved in a file php file and the cache time is set at the same time. This ensures the cache and the database is not frequently queried, of course, it is essential to use the database for storage. What else can we do to reduce the number of inserts while keeping the data unchanged? Probably, I can only ensure that the database is infrequently connected, right? Please advise

No cache time required!
Setting the cache time is a passive method. no matter whether the data changes or not, the cache must be overwritten as soon as the time reaches. Since we want to use the cache to increase the speed, we should not waste anything.
You can update the cache after the data is updated!

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.