Memory allocation
System tenant
The system tenant (sys tenant) is automatically created when OceanBase AI Database is installed. The actual maximum memory available to the sys tenant is hidden_sys_memory + sys_unit_config.memory_size.
Where:
The value of
sys_unit_config.memory_sizeis determined by thememory_sizein the resource specificationsys_unit_config.sys_unit_configis the default resource specification for the system tenant, and its default memory resources are the minimum resources. Since the system tenant is also a normal tenant, you can modify the value ofmemory_sizeinsys_unit_configusing theALTER RESOURCEstatement.The value of
hidden_sys_memoryis controlled by the hidden parameter_hidden_sys_tenant_memory. The default value of the hidden parameter_hidden_sys_tenant_memoryis 0G, which means that the system adaptively allocates the value ofhidden_sys_memoryaccording to certain rules. We recommend that you do not modify the value of the hidden parameter_hidden_sys_tenant_memory.
User tenant
The memory of a user tenant is defined by the memory_size parameter when a unit is created for the user tenant. memory_size specifies the overall memory size of the user tenant, which includes the memory of the user tenant itself and the memory of its corresponding Meta tenant. When you create a user tenant, the minimum memory size allowed is controlled by the hidden parameter __min_full_resource_pool_memory, whose default value is 5G and value range is [1073741824,+∞).
The memory of a user tenant and that of its corresponding Meta tenant can be divided into the MemStore for storing incremental data and the KVCache. For more information about the MemStore, see Non-dynamically scalable memory management. For more information about the KVCache, see Dynamically scalable memory management.
Meta tenant
The memory resources of a Meta tenant cannot be shared, and the memory resources of the Meta tenant and the user tenant must be isolated. By default, a Meta tenant occupies 10% of the overall tenant specification. To ensure the normal operation of a Meta tenant, the minimum memory specification of a Meta tenant is 512 MB, with no upper limit. The memory specification of a user tenant is calculated by subtracting the Meta tenant memory specification from the overall tenant memory specification. The minimum overall tenant specification is adjusted to 1 GB. Examples:
When the tenant specification is greater than or equal to 10 GB, the memory specification ratio between the Meta tenant and the user tenant is 1:9.
When the tenant specification is greater than or equal to 2 GB, the memory specification of the Meta tenant is fixed at 1 GB, and the remaining resources are allocated to the user tenant.
When the tenant specification is greater than or equal to 1 GB and less than 2 GB, the Meta tenant is allocated a fixed 512 MB, and the remaining resources are allocated to the user tenant.
Memory management
OceanBase AI Database divides the memory of each tenant into the following two categories:
Non-dynamically scalable memory
Dynamically scalable memory (KVCache)
The non-dynamically scalable memory is intended for a MemStore that stores incremental data. The dynamically scalable memory is managed by a KVCache (including row_cache and schema_cache).
In addition, many memory components, including the plan cache (for caching execution plans), the SQL area (memory for SQL statement execution), and actions such as election, occupy a specific amount of memory resources. You can query the oceanbase.GV$OB_MEMORY view to check the usage of all memory components.
Non-dynamically scalable memory management
memstore_limit_percentage and ob_sql_work_area_percentage are the only parameters related to the non-dynamically scalable memory. The former specifies the maximum percentage of the tenant memory that the MemStore can occupy, and the latter specifies the maximum size of memory occupied by the workspace of SQL blocking operators.
Data writes and updates in a tenant increase the MemStore usage. When the MemStore usage reaches the upper limit, subsequent write or update operations are denied.
OceanBase AI Database determines when to perform a minor compaction or major compaction to release MemStore memory based on the memory usage ratio of the MemStore. This ratio is controlled by the freeze_trigger_percentage parameter, which specifies the percentage of the MemStore memory limit at which a freeze (the preliminary step before a minor compaction) is triggered. By default, this value is 20% of the tenant's MemStore memory limit.
Dynamically scalable memory management
A KVCache uses the memory other than the non-dynamically scalable memory if possible. When the tenant memory is used up, the memory that is not referenced in the KVCache is evicted first to free up space.
OceanBase AI Database consolidates the vast majority of KV-formatted caches into the KVCache for unified management. The KVCache supports dynamic scaling, priority control for different types of caches, and an intelligent eviction mechanism.
Generally, no configuration is required for the KVCache. In special scenarios, you can control the priorities of various caches through parameters. Caches with higher priorities are more likely to be retained than those with lower priorities.
The following table describes the parameters used to control the priorities of different types of caches. A larger parameter value indicates a higher priority.
Parameter |
Description |
|---|---|
| tablet_ls_cache_priority | The priority of tablet_ls_cache in the cache system. |
| index_block_cache_priority | The priority of index_block_cache in the cache system. |
| user_block_cache_priority | The priority of user_block_cache in the cache system. |
| user_row_cache_priority | The priority of user_row_cache in the cache system. |
| bf_cache_priority | The priority of the Bloom filter in the cache system. |
| fuse_row_cache_priority | The priority of fuse_row_cache in the cache system. |
| opt_tab_stat_cache_priority | The priority of opt_tab_stat_cache in the cache system. |
You can query the oceanbase.GV$OB_KVCACHE view for information about different types of caches in the KVCache. The key components of the sys tenant and a user tenant are slightly different:
Cache types in the sys tenant
CategoryDescriptionschema_cache Stores user schemas and the metadata of database objects required for SQL statements and the normal operation of the system. tablet_table_cache Caches the mappings between schema versions and table IDs in tablets. vtable_cache Caches the location information of tables. index_block_cache Caches microblock indexes to accelerate access to microblock data. user_block_cache Caches microblock data. To improve query performance, the cache stores decompressed microblock data, which may be compressed by a compression algorithm. user_row_cache Caches hot row data in a table. bf_cache Caches Bloom filters for macroblocks whose query results are empty for a specified number of times. This improves the efficiency of filtering empty queries. fuse_row_cache Caches snapshot data of rows to improve the performance of point queries and avoid cache invalidation caused by minor and major compactions. opt_table_stat_cache Caches statistics such as the number of rows, macroblocks, and microblocks in a partition. opt_column_stat_cache Caches statistics such as the number of null values, non-null values, maximum value, and minimum value of a column in a partition. Cache types in a user tenant
CategoryDescriptionindex_block_cache Caches microblock indexes to accelerate access to microblock data. user_block_cache Caches microblock data. To improve query performance, the cache stores decompressed microblock data, which may be compressed by a compression algorithm. user_row_cache Caches hot row data in a table. bf_cache Caches Bloom filters for macroblocks whose query results are empty for a specified number of times. This improves the efficiency of filtering empty queries. fuse_row_cache Caches snapshot data of rows to improve the performance of point queries and avoid cache invalidation caused by minor and major compactions. tmp_block_cache Caches temporary files as a write buffer and write cache. tmp_page_cache Caches temporary files as a read cache. opt_table_stat_cache Caches statistics such as the number of rows, macroblocks, and microblocks in a partition. opt_column_stat_cache Caches statistics such as the number of null values, non-null values, maximum value, and minimum value of a column in a partition.