For more information about phpmysql query efficiency, I need to upload the data in an excel file to the mysql database and query the ID card column in the excel file, if the same ID card already exists in the database, this record is not imported. Currently, I use this statement to query: SELECTidFROMinformationWHEREidcard $ sfzLIMIT1. if the returned results are returned, ask the php mysql Query efficiency question.
I need to upload data from an excel file to the mysql database, and query the ID card column in the excel file. if the database already has the same ID card, this record will not be imported.
Currently, I use this statement to query:
SELECT id FROM information WHERE idcard = '$ sfz' LIMIT 1
If the number of returned results is greater than 0, it exists.
However, it takes nearly one minute to insert more than 5000 data records into the database after such a record is queried and determined.
Is there any better way?
------ Solution --------------------
So there's nothing wrong with that. Or you can add an index to the idcard.
However, if you select an INSERT statement once, it takes time to update the index.
Or set the time delay for mysql index update,
Otherwise, add a tag to the record after all the select statements and then insert the record.
------ Solution --------------------
The landlord has not solved the problem .........
As mentioned above, if you test the optimization, select the one.
No specific data or code.
The solution depends on your own debugging and testing.