Db2 Study Notes-Impact of Data Types on tables
When creating a table, you can select a proper data type for the column to improve the database performance. 1. select an appropriate data type to avoid data type conversion. For example, some people use a string to store the date and timestamp. Finally, we also need to use to_date in the program for data type conversion, which will affect the performance of the application. 2. select an appropriate length. For example, the empno field can be used to store employee numbers, and small int can be used. However, if we use int, two bytes will be wasted. 3. If a field in the table is a number, we recommend that you use an integer instead of char. 4. Select char and varchar. If the data in a column does not change much, char is recommended because the read performance of varchar is divided into read-only and read-only data, which is weaker than char. 5. long varchar, blog, clog, and cblog data types. The data types of these large objects are read directly without going through the memory. Check whether varchar can be used as needed; if you use the big object data type, consider whether to record the log not logged for this large object column; Consider storing the big object data column separately in an independent tablespace, separated from the index data.