MySQL user table data statistics, please provide the best and feasible solutions.

Source: Internet
Author: User
There are 0.9 million records in the MySQL user table, with each record only having the user's registered IP address. Now I want to calculate the number of registered users in each province based on the province of registration. Please provide the best and feasible solutions? There are 0.9 million records in the MySQL user table, with each record only having the user's registered IP address. Now I want to calculate the number of registered users in each province based on the province of registration. Please provide the best and feasible solutions?

Reply content:

There are 0.9 million records in the MySQL user table, with each record only having the user's registered IP address. Now I want to calculate the number of registered users in each province based on the province of registration. Please provide the best and feasible solutions?

1. Obtain the province information through IP Address: http://www.ipip.net/api.html.
Million pieces of data, add an index to the province, and then perform regular statistics. This statistical data does not need to be run frequently.
3. When the data is larger, you can consider recording the number of newly registered users each day in the cache separately, and using the old total number + the new number each day is OK.
4. Wait for the data to be bigger and bigger ...... (Wait until you reach that magnitude)

PS: there is no way to do this. IP is messy. You can calculate which IP segment is in the same province by yourself, which can reduce the query API. If you want to query by province, the province field cannot be omitted. Also, if you change the registration mode, you should record the province during registration. You can decide whether to use the IP address or enter it by yourself. By the way, Gao chunhui's ipip.net does not like others to run data on it. He was annoyed when I saw it on Weibo last time.

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.