txt-php working with text and working with MySQL efficiency issues

Source: Internet
Author: User
Tags mysql query
I want to make a system
Articles such as the need to sort the contents of the operation using MySQL
But for a data layer such as a classification table, I want to store it in text so that I can skip the cache and effectively reduce the number of database queries

I am a little hesitant about this idea, please experts to teach!!

Reply content:

I want to make a system
Articles such as the need to sort the contents of the operation using MySQL
But for a data layer such as a classification table, I want to store it in text so that I can skip the cache and effectively reduce the number of database queries

I am a little hesitant about this idea, please experts to teach!!

I don't know what you're saying about caching.
Caching is used to put data into memory to reduce the IO of persistent storage, why skip it?
For this kind of data, my advice is:

    • Put it in MySQL, easy to edit and query
    • Put a layer of cache, reduce DB IO

1. mysql itself has query cache, which can be considered close to memory performance, and if a small segment of the configuration type of data can be set to constant table to improve read performance.
2. For files, the Linux system also has a memory cache, multiple read performance near the memory speed. Win seemingly the latest system also has to do in-memory file cache.

The respective costs:
1. The cost of MySQL query cache is the re-parsing of TCP connections and SQL
2. Caching of Linux systems is essentially the FD overhead of reading files
Regardless of the caching method, the overhead is data deserialization.

Single case:
Must be the fastest memory cache. If you do not intend to use memory, preferably with MySQL constant table. Although the use of the system cache will be faster, but the file operation involves reading and writing locks, backups, and so on, your own handwriting will be more troublesome--of course, as a practice to try to ensure the integrity of the file data, or if the DB load is high, you can also consider putting files.

Multi-Machine situation:
Basically only MySQL is optional ... Of course you can still store files on one machine, and then write a service for other servers to use.

All in MySQL. Text storage is also to read and write to the disk, the common things can be used memcache cache, direct read memory is certainly faster than the read disk.

You read the disk when you save the text. Read cache is read memory. Definitely read the memory fast.

Still look at the amount of data, if only a few m, that convenient to press which;
Big Point, the back with MySQL storage data, the front to hang a layer of cache, but also to solve most of the application scenario

  • Related Article

    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.