How can I design a large number of multi-level classified data to obtain, cache, and search and query the fastest?

Source: Internet
Author: User
1. large data Volume 2. multilevel Classification 3. obtain all data. 4. after obtaining all the data, there is a search function (no matter how many levels of the searched data, you need to obtain all its parent and child level existence and the search name is marked in red) now I use one to get all the data and search for it later... 1. large data volume
2. multilevel classification
3. obtain all data first
4. after obtaining all the data, you can search for the data. (no matter how many levels of the data you search for, you must obtain all its parent and sub-level data. The search name is marked in red)

Now, in order to get all the data and use a method for subsequent search, I can get all the category IDs and parent subsets together. for example, if the search is not started, all the data must be repeated. de-duplicate and then use these IDs to get all the information and finally recycle and change the font color that matches the search (public to search) finally, the data is recycled and combined into a tree structure.

If the data volume is large, the old cycle may be slow.

How can we optimize the two separate methods for searching and initializing all data?

In addition, I added the cache so that I don't need to re-check the cache for each initialization, but I still need to check the cache for the search. of course, the search may have a small amount of data, but there are too many loops. there is a way to cache it. secondary filtering? The S method cached by the thinkphp framework
Thanks for sharing

Reply content:

1. large data volume
2. multilevel classification
3. obtain all data first
4. after obtaining all the data, you can search for the data. (no matter how many levels of the data you search for, you must obtain all its parent and sub-level data. The search name is marked in red)

Now, in order to get all the data and use a method for subsequent search, I can get all the category IDs and parent subsets together. for example, if the search is not started, all the data must be repeated. de-duplicate and then use these IDs to get all the information and finally recycle and change the font color that matches the search (public to search) finally, the data is recycled and combined into a tree structure.

If the data volume is large, the old cycle may be slow.

How can we optimize the two separate methods for searching and initializing all data?

In addition, I added the cache so that I don't need to re-check the cache for each initialization, but I still need to check the cache for the search. of course, the search may have a small amount of data, but there are too many loops. there is a way to cache it. secondary filtering? The S method cached by the thinkphp framework
Thanks for sharing

  1. Don't feel like loop in most cases, it is several orders of magnitude faster than the database query, unless you use the loop to query the database

  2. In most cases, if you select... in and hit the primary key or index, the result set is within several hundred, and the efficiency is acceptable. you can use it according to your actual situation.

  3. If the data volume is large, there are many filtering conditions, and word segmentation is required, consider the search engine, ElasticSearch, sphtracing, and so on.

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.