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.