DB2 study notes--effects of data types on tables

Source: Internet
Author: User

When you create a table, you can improve database performance by selecting the appropriate data type for the column.

1. Select the appropriate data type to avoid data type conversions. For example, a date, someone using a string to hold the date, timestamp, and finally we will use To_date in the program to do the data type conversion, which will have a performance impact on application performance.

2, choose the right length. For example, a field empno to store the employee number, which can be satisfied with the small int, but if we use int it will result in a two-byte waste.

3. If a field in a table is full of numbers, it is recommended that integers be used instead of char.

4, char and varchar selection; If a column of data does not change much, it is recommended to use char, because the read performance of varchar is divided into read- first-length reread data , which is weaker than char performance.

5, long varchar, blog, clog and cblog data types, these large object data types of reading is not through memory and directly read, depending on the situation can be replaced with varchar, if you use a large object data type, consider whether the large object column log not logged; Consider storing large object data columns separately in a separate tablespace, separated from the index data.

DB2 study notes--effects of data types on tables

Related Article

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.