-
Notifications
You must be signed in to change notification settings - Fork 713
Getting Started with MyRocks
See Build Steps for directions on how to build from source.
To enable RocksDB storage engine (a.k.a. MyRocks), you need to set at least the following parameters in my.cnf.
[mysqld]
rocksdb
default-storage-engine=rocksdb
skip-innodb
default-tmp-storage-engine=MyISAM
collation-server=latin1_bin #(or utf8_bin, binary)
log-bin
binlog-format=ROW
If you want to use both InnoDB and MyRocks within the same instance, set allow-multiple-engines
and remove skip-innodb
in my.cnf. Using mixed storage engines is not recommended in production, because it is not really transactional. But it is ok for experimental purposes.
Statement based binary logging is allowed on replication slave, but not on master. This is because MyRocks does not support next-key locking.
In addition you may want to set some of the following settings :
datadir=<location_for_data_files>
socket=<socket_file>
port=<port>
sql_mode=<mode1>[,<mode2>]
NOTE - this is not exhaustive list of settings by any means, see my.cnf tuning and server variables for more details.
mysql_install_db --defaults-file=/path/to/my.cnf
mysqld_safe --defaults-file=/path/to/my.cnf
CREATE TABLE `linktable` (
`id1` bigint(20) unsigned NOT NULL DEFAULT '0',
`id1_type` int(10) unsigned NOT NULL DEFAULT '0',
`id2` bigint(20) unsigned NOT NULL DEFAULT '0',
`id2_type` int(10) unsigned NOT NULL DEFAULT '0',
`link_type` bigint(20) unsigned NOT NULL DEFAULT '0',
`visibility` tinyint(3) NOT NULL DEFAULT '0',
`data` varchar(255) NOT NULL DEFAULT '',
`time` bigint(20) unsigned NOT NULL DEFAULT '0',
`version` int(11) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (link_type, `id1`,`id2`) COMMENT 'cf_link_pk',
KEY `id1_type` (`id1`,`link_type`,`visibility`,`time`,`version`,`data`) COMMENT 'rev:cf_link_id1_type'
) ENGINE=RocksDB DEFAULT COLLATE=latin1_bin;
The example highlights some important features and limitations in MyRocks. For more on limitations, please read MyRocks Limitations.
-
MyRocks data is stored in RocksDB, per index basis. RocksDB internally allocates a column family to store indexes. By default all data is stored into the
default
column family. You can change the column family by setting theCOMMENT
for a given index. In the example above, the primary key is stored intocf_link_pk
column family, andid1_type
index data is stored intorev:cf_link_id1_type
column family. -
MyRocks has also a feature called reverse column family. Reverse column family is useful if the index is mainly used for descending scan (
ORDER BY ... DESC
). You can configure reverse column family by settingrev:
before the column family name. In this example,id1_type
belongs to a reverse column family. -
For a given table, MyRocks supports storing column families on a per partition basis. More information on how to specify the column families is in Column Families on Partitioned Tables.
Documentation license here.
Installation
MyRocks
- Overview
- Transaction
- Backup
- Performance Tuning
- Monitoring
- Migration
- Internals
- Vector Database
DocStore
- Document column type
- Document Path: a new way to query JSON data
- Built-in Functions for JSON documents
MySQL/InnoDB Enhancements