multiple disparate databases. • Supports various kinds of databases, such as RDBs and NoSQLs. • ScalarDB has been used by some of Fortune Global 500 companies. Relational databases NoSQLs 4 Ref: https://speakerdeck.com/scalar/scalardb-universal-transaction-manager-for-polystores-vldb23
targets mainly transactional workloads and therefore supports limited subsets of relational queries. ScalarDB Analytics with PostgreSQL extends the functionality of ScalarDB to process analytical queries on ScalarDB-managed data by using PostgreSQL and its foreign data wrapper (FDW) extension. https://github.com/scalar-labs/scalardb-analytics-postgresql/blob/main/docs/getting-started.md Online Transaction Processing (OLTP) Online Analytical Processing (OLAP) 5
6 • Users can queries on all ScalarDB-managed Data ◦ Shared data source ◦ ScalarDB Analytics must support all storage supported by ScalarDB • Users can read consistent data ◦ Read-Committed isolation ◦ ScalarDB Analytics must read only committed data Transactional Workload Analytical Workload
Analytics using PostgreSQL and its Foreign Data Wrapper feature. ◦ FDW is a type of PostgreSQL extension to enable users to read external data 7 User ScalarDB PostgreSQL Backend Storage Transactional Workload Analytical Workload FDW
Thanks to the catalog-driven design ▪ Built-ins also work via the catalog ◦ Developers can implement extensions and register them in the system catalog • Extensible Points ◦ SQL Function (Scalar, Aggregate, Window, Table, etc.) ◦ Type ◦ Operator ◦ Index Access Method ◦ Foreign Data Wrapper ◦ Table Access Method (Since PG12) ◦ Planner, Executor Hooks ◦ etc. • See https://www.postgresql.org/docs/15/contrib.html 10
SQL standard ◦ Since PostgreSQL 9 • Register a set of callback functions for Planner and Executor 12 https://www.interdb.jp/pg/pgsql03.html • GetForeignRelSize • GetForeignPaths • GetForeignPlan • BeginForeignScan • IterateForeignScan • EndForeignScan
target list in SELECT) Get table schema metadata in PostgreSQL Initialize with NULLs For each retrieved columns Convert the result value to Datum Generic value type
• Intended to be used as a fall-back option ◦ We can inherently cover all storage supported by ScalarDB 16 CREATE SERVER scalardb FOREIGN DATA WRAPPER scalardb_fdw OPTIONS ( config_file_path '/path/to/scalardb.properties' ); CREATE FOREIGN TABLE sample_table ( pk int, ck1 int, ck2 int, boolean_col boolean, bigint_col bigint, float_col double precision, double_col double precision, text_col text, blob_col bytea ) SERVER scalardb OPTIONS ( namespace 'ns', table_name 'sample_table' ); Question: How can we call ScalarDB library, implemented in Java, from C? Java Native Interface (JNI) Server Definition Table Definition
native code from Java and vice versa ◦ The most conventional FFI framework of Java ◦ Other FFI frameworks do not support calling Java from C… • Cumbersome… ◦ Context (i.e. JavaVM) must be passed everywhere ◦ Complex memory scope (when object is garbage collected?) ◦ Exception handling ◦ Weak typing (everything is Object other than primitive types) ◦ etc. Wrappers of JNI calls FDW callback implementation
by running a series of SQL commands. a. Foreign Data Wrapper b. Foreign Server c. User Mapping d. Schema (Namespace) e. Foreign Table f. WAL-Interpreted view 19
Interpreting the WAL metadata ◦ ScalarDB writes the WAL metadata in each record 20 It is COMMITTED now It has been COMMITTED in the past Use the current value if COMMITTED Use the value in the before image otherwise
Enable serializable transaction among various databases • Introduction to ScalarDB Analytics ◦ Enable analytical queries on ScalarDB-managed data using FDW 21