One-time read out all the data and limit read the data in batches which is good

Source: Internet
Author: User
Read all data at once and limit read data in batches which is good.
At the time of collection, such as the database has 100,000 records URL is the list page URL

1, one-time from the database read out the 100,000 URLs, and then foreach to collect
2, first limit10 bar, foreach collection, and then read the database limit, and constantly repeat

What kind of method is generally used?

Share to:


------Solution--------------------
Collection and analysis separation?
If one side of the collection side analysis, batch
If the separation is one time, of course, the machine can withstand
------Solution--------------------
If you are allowed, why not read it once?
------Solution--------------------
100,000 reads quickly, with limit is how to think out, more trouble, will not improve efficiency.
------Solution--------------------
What does this add limit to do, is not a database query. What efficiency can you improve?
------Solution--------------------
Generally I would suggest reading in batches. If it is important to count a large data set, the best way to do this is to return the statistical results after the server-side has counted the stored procedures. Although the network speed and stability are greatly improved at present, can be done on the server side on the server side do generally always a wrong approach.

But according to the scenario you describe, you need to collect the server-side 100,000 URLs, then I suggest you might as well save a cache of that database locally.
------Solution--------------------
100,000 data, one-time read, no problem, the key is how efficient your collection program.
  • 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.