Answer the question
In order to leave comments, you need to log in
How to optimize ID uniqueness check?
There is a table with a field in which ID of users are stored. The table is constantly updated with new entries. Sometimes, the user ID is entered a second time. Such an entry is checked like this: SELECT * FROM main_db WHERE ident=ID_NUMBER
But this check is somehow slow. Now there are 700k records in the database. Will be around 20k.
How to optimize?
upd: ID is not formed by me
upd2: 600 records were added for 5 hours. This is fine?
Answer the question
In order to leave comments, you need to log in
You can hang a unique index on the field and remove this check:
CREATE UNIQUE INDEX ident
ON main_db (ident);
It must be very fast.
Make sure there is a unique index on the ident field.
If you suddenly need it really, really fast, take redis and store the key-value in it in the form of ident - your id
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question