Enterprise-Class recycling solutions-reducing poor lifting

Source: Internet
Author: User

In the production environment in the face of numerous business processing scenarios, we know to deal with a lot of logic code, which has a call enumeration (also known as a poor lift), when dealing with such transactions, there will be a lot of loop execution, and the cycle is the most CPU-intensive, a large number of iterative calculations, can directly pull down the calculation speed, how to

For the choice of the probability of the uncertainty of the transaction, there will be a certain regularity, such as the probability of the event, according to the knowledge of probability theory, we can go to statistical poor lifting the frequency of each, according to its size in order, so that the previous enumeration items can consume most of the data, the remaining low-probability enumeration will be executed with the minimum

For example, there are 1 million data, there are 50 enumerated items, if the average 25 times can find a match, it will need to run 25 million times (2.5*10 7 times)

A different idea: if the first enumeration item is 30%,2 is 25%,3 is 20% so the first three items on the consumption 750000*3+250000*25=8500000 (8.5*10 6 Parties)

A direct reduction of the number of executions of an order of magnitude, of course these are assumptions, is not very accurate

But the idea is the same, that is, the occurrence of high probability of the event statistics priority, which is in line with the law of life, but also in line with the objective law of the development of affairs.

There are too many scenarios, examples:

Example one: The network operator wants to analyze the user's Internet behavior analysis. He will not collect all the resources on the network first, and then to match each user's Internet behavior at some time

The machine will be tired as well. So first sample survey, then analyze most of the user behavior characteristics, according to the sample to obtain statistical resources, and then this with the smallest resource consumption of the largest data, the remaining small probability event.

Example 2:100-degree search term establishment, will also look for samples, statistics of large probability data precision processing, as a frequent search word cache, so that the search fast and accurate, of course, the other unfamiliar terms using machine to deal with. Calculate the weight of the entry every day, so that the weight of the arrangement, so that the approximate rate of more probability, again save speed.

All in all, the development of the law are the same, there will always be a large probability of events, the development of the law is the same thing. Conforms to the 28 law.

Learning a technology depends on the effort, mastery of a technology depends on the understanding. Feel life, feel everything, the boulevard is one.

Enterprise-Class recycling solutions-reducing poor lifting

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.