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
-
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
-
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.
-
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.