Database design optimization (from a ten-year experience architect's Class) __ database

Source: Internet
Author: User

Yesterday listened to a public class, the class is a 10 years experience in the development of the architect, talking about the design of the database optimization and SQL statement optimization, speak very easy to understand, here first the database design optimization to share to everyone.

1. Moderate violations of the paradigm.

If you strictly follow the three paradigms, you will often need to connect many tables in the query, query efficiency is reduced, can combine business requirements, appropriate redundancy.

2. Establish a proper index.

Indexing speeds up query efficiency in some fields, but the update operation slows down and consumes storage space.

Rules established by indexing:

A. Indexed fields must be fields that are often used to make query criteria

B. If the index is a combination of multiple fields, use the field that is often used as the first query criteria. Otherwise, when you query through a single field, the database does not pass through the index query.

C. Indexed fields must be sufficiently differentiated to be indexed with a frequently identical field, with low efficiency.

3. Horizontal Division of the table

If a large amount of data is generated each year, multiple tables can be established by year.

4. Vertical partitioning of tables

If some of the fields in the table are very long, occupy a large space, when the table to retrieve a large number of i/0 operations, you can separate the field out of a table and the original table to establish 1 to 1 relationship.

5. Select the appropriate field type, such as using varchar instead of char as much as possible.

6. File pictures and other large files using hard disk storage, the database only store the file path.

7. Foreign key to express clearly, the actual work is rarely established foreign keys.

8. Centralized bulk operation is better than frequent read and write operation.

9. Choose the right engine.


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.