May I ask questions about phpmysql query efficiency?

Source: Internet
Author: User
Tags php mysql php mysql query mysql index
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.

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.