For example, the registration site shows "This user name has been used", "The mailbox has been used", all through Ajax in the background to find out whether the user name or mailbox in MySQL exists, there is no easy way, without MySQL, can quickly find a data in big data such as user name or mailbox already exist?
Reply content:
For example, the registration site shows "This user name has been used", "The mailbox has been used", all through Ajax in the background to find out whether the user name or mailbox in MySQL exists, there is no easy way, without MySQL, can quickly find a data in big data such as user name or mailbox already exist?
Long time no see. Not and background communication of course is not, query results can not be produced out of thin air. However, this requirement does not necessarily require a full-featured SQL database.
You can use MySQL in the system itself, and then add a set of Redis cache system all the user name (or other need unique entries) in case of quick query.
The bottom of Redis is a hash table, and the efficiency of a hash table cannot be exceeded. While the volume of data is huge, REDIS can support distributed deployment directly, and it is very convenient to divide and distribute completely without user programming.
Of course, the specific plan depends on your application example. But in addition to "too little data to cache" and "enough data to go directly to Redis," it's hard to think of other better scenarios.
If not indexed, the worst case is O (n) over, which is unacceptable in the production environment
So the index is always indexed, and this index is used in relation to the repository or something else.
Redis is the simplest way to quickly determine if a user's name exists.