How to speed up database update

Source: Internet
Author: User

You don't have to worry about how to increase the speed of database update .. See the following SQL statement.

[Java] String SQL = "update cats set name_alias = '" + rs. getString (1) + "'where name = '" + rs. getString (1) + "'";

 

If the data volume is small, there will certainly be no problem. It will be updated in the twinkling of an eye. However, if a table is larger than a few millions of records, tens of thousands of records would have taken an hour. The solution is that the fields in the where condition must be indexed. Generally, you can directly use the primary index of the table. For example, in the following SQL statement, id is the primary index.
[Java] String SQL = "update cats set name_alias = '000000' where id = '" + rs. getInt (1) + "'";

 

After this optimization, the update speed will increase significantly, and tens of thousands of update operations can be completed in just a few minutes.

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.