What is the primary use of RocksDB column families?

Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: rocksdb列簇主要用来做什么

| username: alfred

【TiDB Usage Environment】Production Environment or Test Environment or POC
【TiDB Version】
【Encountered Problem】
【Reproduction Path】What operations were performed that led to the problem
【Problem Phenomenon and Impact】

【Attachments】 Relevant logs and monitoring (https://metricstool.pingcap.com/)


If the question is related to performance optimization or troubleshooting, please download the script and run it. Please select all and copy-paste the terminal output results for upload.

| username: forever | Original post link

A column family is equivalent to a combination of certain columns, isolating the storage of different columns in a table. Different columns have different storage directories. You can look into HBase; this structure is quite similar to RocksDB and has more available resources.

| username: ddhe9527 | Original post link

Column families are equivalent to logical partitions in RocksDB; they share the WAL but can be used to store different data. In TiDB, the RocksDB that stores data includes four column families: Default CF, Write CF, Lock CF, and Raft CF. The first three CFs correspond to the data column, write column, and lock column in the Percolator transaction model, respectively, meaning they are used to store different columns of data in the Percolator transaction model. Raft CF is used to store the metadata of each Region in the current TiKV instance.

| username: alfred | Original post link

Does it not support manually creating CF?

| username: ddhe9527 | Original post link

In theory, you can manually create CF through RocksDB’s CreateColumnFamily method, but the TiDB transaction model will only use the above four CFs created in kvdb.

| username: wish-PingCAP | Original post link

Hi,

TiKV only uses four ColumnFamilies in RocksDB: write, default, lock, and raft. The first three correspond to the three columns in the Percolator algorithm. For more details, you can refer to TiKV | Percolator

During the write and read processes, the write, default, and lock Column Families are all actually involved.

| username: TiDBer_jYQINSnf | Original post link

RocksDB is a single-node key-value database where column families can be created freely like in HBase. Each column family independently occupies memtable/immutable memtable, and flush and compact operations are also separate. Different column families share the WAL (Write-Ahead Log) to achieve atomic writes across multiple column families in RocksDB.

TiKV uses the single-node version of RocksDB to create a distributed key-value store and has fixed the creation of four column families.

| username: alfred | Original post link

That is to say, in addition to the four fixed column families created, can you create specified column families when creating a table yourself?

| username: forever | Original post link

If it is TiDB, then RocksDB is just a storage component of TiDB. The column families are predefined and cannot be defined by yourself. If you are using RocksDB directly, you can define them as needed.

| username: alfred | Original post link

Got it, column families are only relevant to RocksDB.

| username: 特雷西-迈克-格雷迪 | Original post link

Column families are just for grouping key-values with the same format together, making storage and management more convenient.

| username: system | Original post link

This topic was automatically closed 1 minute after the last reply. No new replies are allowed.