Memory Connector

The Memory connector stores all data and metadata in RAM on workers and both are discarded when Presto restarts.

Configuration

To configure the Memory connector, create a catalog properties file etc/catalog/memory.properties with the following contents:

  1. connector.name=memory
  2. memory.max-data-per-node=128MB

memory.max-data-per-node defines memory limit for pages stored in this connector per each node (default value is 128MB).

Examples

Create a table using the Memory connector:

  1. CREATE TABLE memory.default.nation AS
  2. SELECT * from tpch.tiny.nation;

Insert data into a table in the Memory connector:

  1. INSERT INTO memory.default.nation
  2. SELECT * FROM tpch.tiny.nation;

Select from the Memory connector:

  1. SELECT * FROM memory.default.nation;

Drop table:

  1. DROP TABLE memory.default.nation;

SQL Support

The Memory connector allows querying and creating tables and schemas in memory. Here are some examples of the SQL operations supported:

CREATE SCHEMA

Create a new schema named default1:

  1. CREATE SCHEMA memory.default1;

CREATE TABLE

Create a new table named my_table in the default1 schema:

  1. CREATE TABLE memory.default1.my_table (id integer, name varchar, age integer);

INSERT INTO

Insert data into the my_table table:

  1. INSERT INTO memory.default1.my_table (id, name, age) VALUES (1, 'John Doe', 30);

SELECT

Select data from the my_table table:

  1. SELECT * FROM memory.default1.my_table;

DROP TABLE

To delete an existing table:

  1. DROP TABLE memory.default.nation;

Note

After using DROP TABLE, memory is not released immediately. It is released after the next write access to the memory connector.

Memory Connector Limitations

The following SQL statements are not supported:

Limitations

  • When one worker fails or restarts, all data stored in its memory is lost forever. To prevent silent data loss, this connector generates an error on any read access to such a corrupted table.

  • When a query fails for any reason during writing to memory table, the table is in undefined state. Such a table should be dropped and recreated manually. Reading from such tables may fail or may return partial data.

  • When the coordinator fails or restarts, all metadata about tables is lost. The tables’ data is still present on the workers, but that data is inaccessible.

  • This connector will not work properly with multiple coordinators, because each coordinator has a different metadata.