Updated on 2024-08-20 GMT+08:00

Setting Up a Storage Engine

The storage engine has a great impact on the overall efficiency and performance of the database. Select a proper storage engine based on the actual requirements. You can run WITH ( [ORIENTATION | STORAGE_TYPE] [= value] [, ... ] ) to specify an optional storage parameter for a table or index. The parameters are described as follows.

ORIENTATION

STORAGE_TYPE

ROW (default value): The data will be stored in rows.

[USTORE (default value)|ASTORE|Null]

If ORIENTATION is set to ROW and STORAGE_TYPE is left empty, the type of the created table is determined by the value of the enable_default_ustore_table parameter. The parameter value can be on or off. The default value is on. For details about the parameter, see "Configuring GUC Parameters > GUC Parameters" in Administrator Guide. If this parameter is set to on, a Ustore table is created. If this parameter is set to off, an Astore table is created.

Example:

gaussdb=# CREATE TABLE TEST(a int);
gaussdb=# \d+ test
                         Table "public.test"
 Column |  Type   | Modifiers | Storage | Stats target | Description
--------+---------+-----------+---------+--------------+-------------
 a      | integer |           | plain   |              |
Has OIDs: no
Options: orientation=row, compression=no, storage_type=USTORE, segment=off

gaussdb=# CREATE TABLE TEST1(a int) with(orientation=row, storage_type=ustore);
gaussdb=# \d+ test1
Table "public.test1"
 Column |  Type   | Modifiers | Storage | Stats target | Description
--------+---------+-----------+---------+--------------+-------------
 a      | integer |           | plain   |              |
Has OIDs: no
Options: orientation=row, storage_type=ustore, compression=no, segment=off

gaussdb=# CREATE TABLE TEST2(a int) with(orientation=row, storage_type=astore);
gaussdb=# \d+ test2
Table "public.test2"
 Column |  Type   | Modifiers | Storage | Stats target | Description
--------+---------+-----------+---------+--------------+-------------
 a      | integer |           | plain   |              |
Has OIDs: no
Options: orientation=row, storage_type=astore, compression=no

gaussdb=#  CREATE TABLE test4(a int) with(orientation=row);
gaussdb=# \d+
                                                       List of relations
 Schema | Name  | Type  |   Owner   |  Size   |                             Storage                              | Description
--------+-------+-------+-----------+---------+------------------------------------------------------------------+-------------
 public | test  | table | z7ee88f3a | 0 bytes | {orientation=row,compression=no,storage_type=USTORE,segment=off} |
 public | test1 | table | z7ee88f3a | 0 bytes | {orientation=row,storage_type=ustore,compression=no,segment=off} |
 public | test2 | table | z7ee88f3a | 0 bytes | {orientation=row,storage_type=astore,compression=no}             |
 public | test3 | table | z7ee88f3a | 16 kB   | {orientation=column,storage_type=astore,compression=low}         |
 public | test4 | table | z7ee88f3a | 0 bytes | {orientation=row,compression=no,storage_type=USTORE,segment=off} |
(5 rows)

gaussdb=# show enable_default_ustore_table;
 enable_default_ustore_table
-----------------------------
 on
(1 row)

gaussdb=#  DROP TABLE test;
gaussdb=#  DROP TABLE test1;
gaussdb=#  DROP TABLE test2;
gaussdb=#  DROP TABLE test4;