All Projects → vidardb → pgrocks-fdw

vidardb / pgrocks-fdw

Licence: Apache-2.0 license
Bring RocksDB to PostgreSQL as an extension. It is the first foreign data wrapper (FDW) that introduces LSM-tree into PostgreSQL. The underneath storage engine can be RocksDB. The FDW also serves for VidarDB engine, a versatile storage engine for various workloads. See the link for more info about VidarDB engine.

Programming Languages

c
50402 projects - #5 most used programming language
C++
36643 projects - #6 most used programming language
shell
77523 projects
perl
6916 projects
Makefile
30231 projects
Dockerfile
14818 projects
CMake
9771 projects

Projects that are alternatives of or similar to pgrocks-fdw

rippledb
Embeddable key-value database engine in pure TypeScript, based on LSM-Tree
Stars: ✭ 33 (-67.33%)
Mutual labels:  rocksdb, storage-engine, leveldb, lsm-tree
Level Rocksdb
A convenience package bundling levelup and rocksdb.
Stars: ✭ 120 (+18.81%)
Mutual labels:  rocksdb, leveldb
Ardb
A redis protocol compatible nosql, it support multiple storage engines as backend like Google's LevelDB, Facebook's RocksDB, OpenLDAP's LMDB, PerconaFT, WiredTiger, ForestDB.
Stars: ✭ 1,707 (+1590.1%)
Mutual labels:  rocksdb, leveldb
ssdb
SSDB - A fast NoSQL database, an alternative to Redis
Stars: ✭ 8,026 (+7846.53%)
Mutual labels:  rocksdb, leveldb
Benchmarks
Benchmark of open source, embedded, memory-mapped, key-value stores available from Java (JMH)
Stars: ✭ 116 (+14.85%)
Mutual labels:  rocksdb, leveldb
Fastonosql
FastoNoSQL is a crossplatform Redis, Memcached, SSDB, LevelDB, RocksDB, UnQLite, LMDB, ForestDB, Pika, Dynomite, KeyDB GUI management tool.
Stars: ✭ 1,001 (+891.09%)
Mutual labels:  rocksdb, leveldb
Srchx
A standalone lightweight full-text search engine built on top of blevesearch and Go with multiple storage (scorch, boltdb, leveldb, badger)
Stars: ✭ 118 (+16.83%)
Mutual labels:  rocksdb, leveldb
rust-rocks
Make RocksDB really rocks! The Rust style API.
Stars: ✭ 41 (-59.41%)
Mutual labels:  rocksdb, lsm-tree
duckdb fdw
DuckDB Foreign Data Wrapper for PostgreSQL
Stars: ✭ 88 (-12.87%)
Mutual labels:  fdw, foreign-data-wrapper
database-engine
LSM-Tree Key-Value Store based on RocksDB
Stars: ✭ 47 (-53.47%)
Mutual labels:  rocksdb, lsm-tree
Rocksdb
Pure C++ Node.js RocksDB binding. An abstract-leveldown compliant store.
Stars: ✭ 138 (+36.63%)
Mutual labels:  rocksdb, leveldb
docker-mongo
MongoDB Docker image embedding RocksDB storage engine
Stars: ✭ 32 (-68.32%)
Mutual labels:  rocksdb
Construct
This is The Construct
Stars: ✭ 218 (+115.84%)
Mutual labels:  rocksdb
Rocksdb Doc Cn
中文版rocksdb文档
Stars: ✭ 118 (+16.83%)
Mutual labels:  rocksdb
iota-python
A Pure-Python implementation of IOTA node
Stars: ✭ 30 (-70.3%)
Mutual labels:  rocksdb
Tikv
Distributed transactional key-value database, originally created to complement TiDB
Stars: ✭ 10,403 (+10200%)
Mutual labels:  rocksdb
JukeboxMC
A Minecraft Bedrock Editon Server Software
Stars: ✭ 56 (-44.55%)
Mutual labels:  leveldb
Rocksdb Sharp
.net bindings for the rocksdb by facebook
Stars: ✭ 173 (+71.29%)
Mutual labels:  rocksdb
Sharkstore
distributed key - value persisted storage system
Stars: ✭ 165 (+63.37%)
Mutual labels:  rocksdb
hub
No description or website provided.
Stars: ✭ 12 (-88.12%)
Mutual labels:  rocksdb

pgrocks-fdw

Build Status

This PostgreSQL extension implements a Foreign Data Wrapper (FDW) for RocksDB. This repo has been listed in PostgreSQL wiki. We are also building an extension to supercharge PostgreSQL analytics. It's not product ready yet, but if you are interested, please contact us at [email protected] to gain access.

RocksDB is a high performance key-value store based on a log-structured merge-tree (LSM tree). RocksDB can efficiently use many CPU cores and fast storage. This is the first foreign data wrapper that connects a LSM-tree-based storage engine to PostgreSQL. Because RocksDB is an embeddable key-value store, you do not need to run another server to use this extension.

This extension can also be used for other systems that have RocksDB-like APIs, but please check the compatibility before you use this extension for other systems.

This extension is developed and maintained by the VidarDB team. Currently only works for PG13. Feel free to report bugs or issues via Github.

Building

We test this foreign data wrapper on Ubuntu Server 20.04 using PostgreSQL-13 together with RocksDB-6.11.4 (built with GCC-9.3.0).

  • Install PostgreSQL and the dev library which is required by extensions:

    # add the repository
    sudo tee /etc/apt/sources.list.d/pgdg.list << END
    deb http://apt.postgresql.org/pub/repos/apt/ bionic-pgdg main
    END
    
    # get the signing key and import it
    wget https://www.postgresql.org/media/keys/ACCC4CF8.asc
    sudo apt-key add ACCC4CF8.asc
    
    # fetch the metadata from the new repo
    sudo apt-get update
    
    # install postgresql and the dev library
    sudo apt-get install postgresql-13
    sudo apt-get install postgresql-server-dev-13
  • Install RocksDB from source code:

    git clone -b v6.11.4 https://github.com/facebook/rocksdb.git
    
    cd rocksdb
    
    sudo DEBUG_LEVEL=0 make shared_lib install-shared
    
    sudo sh -c "echo /usr/local/lib >> /etc/ld.so.conf"  
    
    sudo ldconfig
  • Build this foreign data wrapper:

    git clone https://github.com/vidardb/pgrocks-fdw.git
    
    cd pgrocks-fdw 
    
    make
    
    sudo make install

    To build the foreign data wrapper for VidarDB [ version <= 1.0.0 ], add flag VIDARDB=true to the above make command.

  • Before using this foreign data wrapper, we need to add it to shared_preload_libraries in the postgresql.conf:

    sudo bash -c 'echo "shared_preload_libraries = 'kv_fdw'" >> /etc/postgresql/13/main/postgresql.conf'

    and restart PostgreSQL:

    sudo service postgresql restart
  • When uninstall this extension, first issue the following commands, and then delete the data by locating PostgreSQL data folder via show data_directory; in PostgreSQL terminal.

    cd pgrocks-fdw 
    
    sudo make uninstall

Limitations

  • The first attribute in the table definition must be the primary key. Composite primary key can be achieved via creating a new data type CREATE TYPE ... AS.

  • Currently no rollback, abort.

  • Currently once the table is created, cannot drop or add columns.

  • Do not support secondary index.

Usage

This extension does not have any parameter. After creating the extension and corresponding server, you can use RocksDB as a foreign storage engine for your PostgreSQL.

A simple example is as follows (you can run 'sudo -u postgres psql -U postgres' to connect the local postgresql server):

    CREATE DATABASE example;  
    \c example  

    CREATE EXTENSION kv_fdw;  
    CREATE SERVER kv_server FOREIGN DATA WRAPPER kv_fdw;  

    CREATE FOREIGN TABLE student(id INTEGER, name TEXT) SERVER kv_server;  

    INSERT INTO student VALUES(20757123, 'Rafferty');  
    SELECT * FROM student;  

    INSERT INTO student VALUES(20767234, 'Jones');  
    SELECT * FROM student;  

    DELETE FROM student WHERE name='Jones';  
    SELECT * FROM student;  

    UPDATE student SET name='Tom' WHERE id=20757123;  
    SELECT * FROM student;  

    DROP FOREIGN TABLE student;  

    DROP SERVER kv_server;  
    DROP EXTENSION kv_fdw;  
  
    \c postgres  
    DROP DATABASE example;  

Testing

We have tested certain typical SQL statements and will add more test cases later. The test scripts are in the sql folder which are recommended to be placed in a non-root directory. The corresponding results can be found in the expected folder. You can run the tests in the following way:

    sudo service postgresql restart  

    cd pgrocks-fdw 

    sudo -u postgres psql -U postgres -a -f sql/create.sql 

    sudo -u postgres psql -U postgres -d kvtest -a -f sql/test.sql 

    sudo -u postgres psql -U postgres -d kvtest -a -f sql/clear.sql  

Debug

If you want to debug the source code, you may need to start PostgreSQL in the debug mode:

    sudo service postgresql stop  

    sudo -u postgres /usr/lib/postgresql/13/bin/postgres -d 0 -D /var/lib/postgresql/13/main -c config_file=/etc/postgresql/13/main/postgresql.conf

Docker

We can also run PostgreSQL with RocksDB in Docker container and you can refer to here.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].