In-memory databases can be compressed to conserve memory and persistent database data and log files can be compressed to conserve disk space. Data can also be encrypted for security.
In-memory compression
For in-memory database compression the configuration file option db_params:mode_mask must be set with the
inmemory_compressionflag value. It is also possible to explicitly set the optionspage_hash_bundles,compression_level,compression_mask, andexpected_compression_ratio. For example:db_params: { mode_mask: in_memory_compression, page_hash_bundles: 8, compression_level: 1, compression_mask: 3, expected_compression_ratio: 4 }Persistent database compression
Note that, as explained in Data Compression, disk file compression is supported only on Unix-Linux platforms.
To enable compression with eXtremeDB, the configuration file must specify which file to compress (or is compressed) and which special file system library to load to manage the compression. (The database files must use library
mcofu98zip, while log files use librarymcofu98ziplog.)For example, to compress the persistent database file
test.dbs, the configuration file would specify the flag valuecompressedfor the file device and use librarymcofu98zipwith the following option settings:devices : [ {assignment: database, size : 100m}, {assignment: cache, size : 100m}, {type:file, assignment : persistent, name : test.dbs, flags: compressed}, {type:file, assignment : log, name : test.log}, ], runtime_configuration: { fs_library: mcofu98zip, }
To compress the log file
test.log, the configuration file would contain the following options:devices : [ {assignment: database, size : 100m}, {assignment: cache, size : 100m}, {type:file, assignment : persistent, name : test.dbs}, {type:file, assignment : log, name : test.log, flags: compressed }, ], runtime_configuration: { fs_library: mcofu98ziplog, }(Note that if both database and log files need to be compressed, xSQL must be run twice, once with
mcofu98zipfor the database file(s) and once withmcofu98ziplogfor the log file - only one file system library, eithermcofu98zipormcofu98ziplogcan be loaded at a time.)Data Compression for IoT Communications
Data compression for IoT communications is enabled by setting the
compression_levelparameter of theiot_paramsconfiguration file section (which corresponds to thecompression_levelelement of structuremco_iot_comm_paramst_t).Also, as explained in the Data Compression page is the formula used to determine the compression ratio. The
xsql_iot_list()SQL function can be called to retrieve the statistics for a connection; fieldsrx_zratioandtx_zratioof returned Result Set (which correspond to elementssent_compression_ratioandrecv_compression_ratioof structuremco_iot_connection_stat_t) show the compression efficiency for incoming and outgoing communications.
Data Encryption
To encrypt a disk database, the configuration file section db_params must contain the
cipher_keyoption:db_params : { cipher_key : "my_secret_password" }