Store Data Efficiently with Column-Based Compression of Tables
Performance impact: Large
This mechanism provides space reduction for tables by eliminating the redundant storage of duplicate values within columns and improves the performance of SQL queries that perform full table scans.
When compressing columns of a TimesTen table, consider the following:
-
Compress a column if values are repeated throughout such as the name of countries or states.
-
Compress a column group if you often access multiple columns together.
-
Do not compress columns that contain data types that require a small amount of storage such as
TT_TINYINT. -
TimesTen does not compress
NULLvalues.
You can define one or more columns in a table to be compressed together, which is called a compressed column group. You can define one or more compressed column groups in each table.
A dictionary table is created for each compressed column group that contains a column with all the distinct values of the compressed column group. The compressed column group now contains a pointer to the row in the dictionary table for the appropriate value. The width of this pointer can be 1, 2, or 4 bytes long depending on the maximum number of entries you defined for the dictionary table. So if the sum of the widths of the columns in a compressed column group is wider than the 1, 2, or 4 byte pointer width, and if there are a lot of duplicate values of those column values, you have reduced the amount of space used by the table.
Figure 10-1 shows the compressed column group in the table pointing to the appropriate row in the dictionary table.
Figure 10-1 Column-Based Compression of Tables

Description of "Figure 10-1 Column-Based Compression of Tables"
The dictionary table has a column of pointers to each of the distinct values. When the user configures the maximum number of distinct entries for the compressed column group, the size of the compressed column group is set as follows:
-
1 byte for a maximum number of entries of 255 (28-1). When the maximum number is between 1 and 255, the dictionary size is set to 255 (28-1) values and the compressed column group pointer column is 1 byte.
-
2 bytes for a maximum number of entries of 65,535 (216-1). When the maximum number is between 256 and 65,535, the dictionary size is set to 65,535 (216-1) values and the compressed column group pointer column is 2 bytes.
-
4 bytes for a maximum number of entries of 4,294,967,295 (232-1). When the maximum number is between 65,536 and 4,294,967,295, the dictionary size is set to 4,294,967,295 (232-1) values and the compressed column group pointer column is 4 bytes. This is the default.
Compressed column groups can be added at the time of table creation or added later
using ALTER TABLE. You can drop the entire compressed column group with
the ALTER TABLE statement. See ALTER TABLE and CREATE TABLE
in the Oracle TimesTen In-Memory Database SQL
Reference.
You can call the ttSize built-in procedure to review the level of
compression that TimesTen achieved on your compressed table. For more information on the
ttSize built-in procedure, see ttSize in the Oracle TimesTen In-Memory Database
Reference.